Category: Matlab
Category Archives: Matlab
missing “configure for app” in matlab 2019b app designer
Hi,
I want to creat custom component for matlab app designer .
I cannot find the "configure for app" button?
in addition, I also cannot run it from the commend line:
>> appdesigner.customcomponent.configureMetadata(‘C:funcsBandC1_exported.m’);
Unable to resolve the name appdesigner.customcomponent.configureMetadata.
how to creat it?Hi,
I want to creat custom component for matlab app designer .
I cannot find the "configure for app" button?
in addition, I also cannot run it from the commend line:
>> appdesigner.customcomponent.configureMetadata(‘C:funcsBandC1_exported.m’);
Unable to resolve the name appdesigner.customcomponent.configureMetadata.
how to creat it? Hi,
I want to creat custom component for matlab app designer .
I cannot find the "configure for app" button?
in addition, I also cannot run it from the commend line:
>> appdesigner.customcomponent.configureMetadata(‘C:funcsBandC1_exported.m’);
Unable to resolve the name appdesigner.customcomponent.configureMetadata.
how to creat it? configure, custom component, appdesigner MATLAB Answers — New Questions
How to find norm of a 3 X 1 matrix if it contains components in parametric form?
%i have this coupler matrix in parametric form
syms t
coupler_parametric=[5163136522924301/2251799813685248, 2^(1/2)/2 – (8*t)/(t^2 + 1), – (4*(t^2 – 1))/(t^2 + 1) – 2];
i want to find magnitude of this matrix in terms of t
please someone help%i have this coupler matrix in parametric form
syms t
coupler_parametric=[5163136522924301/2251799813685248, 2^(1/2)/2 – (8*t)/(t^2 + 1), – (4*(t^2 – 1))/(t^2 + 1) – 2];
i want to find magnitude of this matrix in terms of t
please someone help %i have this coupler matrix in parametric form
syms t
coupler_parametric=[5163136522924301/2251799813685248, 2^(1/2)/2 – (8*t)/(t^2 + 1), – (4*(t^2 – 1))/(t^2 + 1) – 2];
i want to find magnitude of this matrix in terms of t
please someone help #symbolic, #matrix MATLAB Answers — New Questions
Driving Open manipulator through Dynamics in Simulink
this is my simulink model for driving my open manipulator 4 DOF robot Dynamics
waypoints
wp = [
0.35 0.25 0.25 0.15 0.15 0.25;
0 0.01 0.11 0.11 0.01 0.01;
0.11 0.11 0.11 0.11 0.11 0.11 ];
error
Error:Error in port widths or dimensions. ‘Output Port 1’ of ‘untitled1/Trapezoidal Velocity Profile Trajectory’ is a [3×1] matrix.
Error:Error in port widths or dimensions. ‘Input Port 1’ of ‘untitled1/Forward Dynamics’ is a one dimensional vector with 6 elements.this is my simulink model for driving my open manipulator 4 DOF robot Dynamics
waypoints
wp = [
0.35 0.25 0.25 0.15 0.15 0.25;
0 0.01 0.11 0.11 0.01 0.01;
0.11 0.11 0.11 0.11 0.11 0.11 ];
error
Error:Error in port widths or dimensions. ‘Output Port 1’ of ‘untitled1/Trapezoidal Velocity Profile Trajectory’ is a [3×1] matrix.
Error:Error in port widths or dimensions. ‘Input Port 1’ of ‘untitled1/Forward Dynamics’ is a one dimensional vector with 6 elements. this is my simulink model for driving my open manipulator 4 DOF robot Dynamics
waypoints
wp = [
0.35 0.25 0.25 0.15 0.15 0.25;
0 0.01 0.11 0.11 0.01 0.01;
0.11 0.11 0.11 0.11 0.11 0.11 ];
error
Error:Error in port widths or dimensions. ‘Output Port 1’ of ‘untitled1/Trapezoidal Velocity Profile Trajectory’ is a [3×1] matrix.
Error:Error in port widths or dimensions. ‘Input Port 1’ of ‘untitled1/Forward Dynamics’ is a one dimensional vector with 6 elements. open manipulator, simulink MATLAB Answers — New Questions
Format output from jsonencode to make it more human readable
Can someone provide an example to format the output from jsonencode to make it more human readable. I.E. add carriage returns and indentations.Can someone provide an example to format the output from jsonencode to make it more human readable. I.E. add carriage returns and indentations. Can someone provide an example to format the output from jsonencode to make it more human readable. I.E. add carriage returns and indentations. jsonencode MATLAB Answers — New Questions
Issues with Quadcopter Deep Reinforcement Learning Training in Simulink
Hi guys,
I’ve been experimenting with training a quadcopter using Simulink in MATLAB for deep reinforcement learning. My objective is to train it to navigate from one hovering point to another point in space. However, I’ve encountered significant challenges, and the results have been far from satisfactory.
Could anyone provide suggestions or insights into potential issues that might be causing this? thank youHi guys,
I’ve been experimenting with training a quadcopter using Simulink in MATLAB for deep reinforcement learning. My objective is to train it to navigate from one hovering point to another point in space. However, I’ve encountered significant challenges, and the results have been far from satisfactory.
Could anyone provide suggestions or insights into potential issues that might be causing this? thank you Hi guys,
I’ve been experimenting with training a quadcopter using Simulink in MATLAB for deep reinforcement learning. My objective is to train it to navigate from one hovering point to another point in space. However, I’ve encountered significant challenges, and the results have been far from satisfactory.
Could anyone provide suggestions or insights into potential issues that might be causing this? thank you drl, quadcopter, agent MATLAB Answers — New Questions
Matlab question signal processing
Using the EMG file (EMG.txt) that was assigned. The sampling frequency is 1000Hz. Use MATLAB to create a subplot of the EMG signal graphed over time, and an amplitude spectrum of the EMG signal.
a. What frequency has the largest power?
b. In general, muscle fatigue is concentrated at lower frequencies (<50Hz). Comment on the muscle fatigue by calculating the % of power in 0-50Hz vs. the total frequency power spectrum. (<20% no fatigue; 20-40% mid; >40% high)Using the EMG file (EMG.txt) that was assigned. The sampling frequency is 1000Hz. Use MATLAB to create a subplot of the EMG signal graphed over time, and an amplitude spectrum of the EMG signal.
a. What frequency has the largest power?
b. In general, muscle fatigue is concentrated at lower frequencies (<50Hz). Comment on the muscle fatigue by calculating the % of power in 0-50Hz vs. the total frequency power spectrum. (<20% no fatigue; 20-40% mid; >40% high) Using the EMG file (EMG.txt) that was assigned. The sampling frequency is 1000Hz. Use MATLAB to create a subplot of the EMG signal graphed over time, and an amplitude spectrum of the EMG signal.
a. What frequency has the largest power?
b. In general, muscle fatigue is concentrated at lower frequencies (<50Hz). Comment on the muscle fatigue by calculating the % of power in 0-50Hz vs. the total frequency power spectrum. (<20% no fatigue; 20-40% mid; >40% high) digital signal processing MATLAB Answers — New Questions
Error en código LSTM. Error in LSTM code
Hola, el siguiente código arroja el siguiente error:
Hello, the following code throws the following error:
clc
clear
close all
A1 = 0.04;
A4 = 0.04;
B1 = 1.5e-4;
B4 = 1.5e-4;
Kp1 = 3.7E-6;
Kp4 = 3.7E-6;
g = 9.8;
v=[12.6101 1.0688 31.0125 37.5489 12.9138 71.4793 95.7939 32.9065 79.1094 67.4771 11.8518 72.6723 88.3776 1.0488 11.0924 37.6680 91.5542 99.8999 17.8789 18.0891 11.2040 61.0086 41.7771 26.3225 20.9668 19.5812 88.4935 63.5100 62.6202 66.1686 18.5314 62.9590 87.7691 18.6421 64.9118 88.5281 25.8011 59.0359 49.2004 84.0695 6.1159 74.2078 55.8971 43.5178 78.1925 40.2701 36.3657 66.2878 40.0230 18.6693 6.3752 25.4650 90.2795 98.2619 48.9268 15.3302 51.6550 99.3592 76.4943 96.6364 93.0582 24.4126 10.6547 41.5677 13.9861 75.7021 35.4622 45.5286 20.7342 73.9153 21.1334 77.0479 24.8867 61.7596 35.2314 72.5405 12.6051 18.8981 20.1926 36.6943 41.0350 23.3522 67.2367 95.7641 43.7348 80.5776 80.0207 99.5289 21.9686 33.5729 76.4718 75.9192 96.1664 57.4193 61.2421 37.1441 35.0112 60.3988 53.0373 49.0117];
p=[65.9094 4.7869 19.8024 92.9458 58.7150 2.5256 30.0739 5.4808 79.6784 71.4252 54.0998 59.0927 21.8838 41.9776 52.0662 83.9952 66.3312 48.6364 85.4237 48.6713 27.9573 73.3884 96.9775 38.1866 24.6214 25.0278 2.8750 98.2827 80.4593 56.7850 39.4941 65.6003 99.3771 71.6628 11.1343 45.2816 69.5867 33.9626 92.2531 63.6166 93.2864 43.1661 30.7485 89.0138 2.7200 15.6575 95.9571 71.7325 31.3402 82.9815 80.9813 91.0163 64.6385 63.2399 12.7286 91.9783 62.7741 26.5009 95.1791 5.5744 3.0718 9.7170 52.2664 87.9877 40.8157 56.5710 60.2174 8.4300 39.7575 36.1435 25.2341 11.6948 12.1166 27.4533 27.3728 93.6720 19.4315 51.2361 15.6118 92.1493 93.0167 14.5384 87.2854 2.2232 72.4816 87.9799 39.3572 25.3966 12.0606 84.8313 66.3062 78.1866 36.4977 19.2294 2.0078 9.5056 33.6173 30.7822 51.1505 39.2739];
sim_in = [v, p];
sim_out = [7.1311 6.3588 6.0545 7.8257 9.1521 8.0623 7.0667 6.2499 6.0917 6.2498 7.5273 7.2557 6.3734 7.3573 8.4913 9.8310 8.9261 7.8193 10.0257 10.6941 10.6282 10.7414 12.1362 12.1442 11.7505 11.4088 10.1702 10.6450 10.8248 10.4919 10.7776 10.6827 10.0315 11.5522 10.4712 9.5101 10.7533 10.1794 11.1625 10.3909 13.2449 12.4087 11.7282 12.7822 11.4824 10.6570 12.2692 12.0873 11.6660 13.5195 15.6611 17.3295 16.0747 14.6372 13.5176 15.7546 15.6847 14.2223 13.8570 12.4838 11.1820 10.2803 11.2498 12.3825 12.6999 12.0127 12.5235 11.4221 11.6250 10.7953 10.4960 9.4175 8.6992 8.0898 7.8539 8.0031 7.7384 8.6275 8.1134 9.7540 11.1313 10.4081 10.5331 9.3326 10.0847 9.6961 8.9038 7.8016 7.2000 8.8101 8.4298 8.2227 7.2229 6.6039 5.6859 5.0770 5.2510 4.9641 5.2480 5.3237];
v_Datastore = arrayDatastore(v);
p_Datastore = arrayDatastore(p);
out_Datastore=arrayDatastore(sim_out);
trainDatastore = combine(v_Datastore, p_Datastore, out_Datastore);
% —————CREATE END TRAIN NETWORK——————
% Network architecture
numResponses = 1;
featureDimension = 1;
numHiddenUnits = 400;
maxEpochs = 400;
miniBatchSize = 300;
Networklayers = [sequenceInputLayer(featureDimension) …
lstmLayer(numHiddenUnits) …
dropoutLayer(0.02),…
fullyConnectedLayer(numResponses) …
regressionLayer
];
options = trainingOptions(‘adam’, …
‘MaxEpochs’,maxEpochs, …
‘MiniBatchSize’,miniBatchSize, …
‘GradientThreshold’,20, …
‘Shuffle’,’once’, …
‘Plots’,’training-progress’,…
‘LearnRateSchedule’,’piecewise’,…
‘LearnRateDropPeriod’,200,…
‘L2Regularization’,1e-3,…
‘LearnRateDropFactor’,0.5,…
‘Verbose’,0,…
‘ValidationData’,[{sim_in} {sim_out}]);
% ENTRENAMIENTO
net = trainnet(trainDatastore, Networklayers,options);
Falta un argumento en la llamada a la función pero no se cuál poner. Gracias.
There is a missing argument in the function call but I don’t know which one to put. Thank you.
Si pongo trainNetwork el error es:
If I put trainNetwork the error is:
Error using trainNetwork (line 191)
Invalid validation data. Sequence responses must have the same sequence length as the
corresponding predictors.
Error in miso_directo (line 52)
net = trainNetwork(trainDatastore,Networklayers,options);
Tengo dos entradas de 100 elementos y una salida de 100 elementos.
I have two inputs of 100 elements and one output of 100 elements.
Gracias. Thanks.Hola, el siguiente código arroja el siguiente error:
Hello, the following code throws the following error:
clc
clear
close all
A1 = 0.04;
A4 = 0.04;
B1 = 1.5e-4;
B4 = 1.5e-4;
Kp1 = 3.7E-6;
Kp4 = 3.7E-6;
g = 9.8;
v=[12.6101 1.0688 31.0125 37.5489 12.9138 71.4793 95.7939 32.9065 79.1094 67.4771 11.8518 72.6723 88.3776 1.0488 11.0924 37.6680 91.5542 99.8999 17.8789 18.0891 11.2040 61.0086 41.7771 26.3225 20.9668 19.5812 88.4935 63.5100 62.6202 66.1686 18.5314 62.9590 87.7691 18.6421 64.9118 88.5281 25.8011 59.0359 49.2004 84.0695 6.1159 74.2078 55.8971 43.5178 78.1925 40.2701 36.3657 66.2878 40.0230 18.6693 6.3752 25.4650 90.2795 98.2619 48.9268 15.3302 51.6550 99.3592 76.4943 96.6364 93.0582 24.4126 10.6547 41.5677 13.9861 75.7021 35.4622 45.5286 20.7342 73.9153 21.1334 77.0479 24.8867 61.7596 35.2314 72.5405 12.6051 18.8981 20.1926 36.6943 41.0350 23.3522 67.2367 95.7641 43.7348 80.5776 80.0207 99.5289 21.9686 33.5729 76.4718 75.9192 96.1664 57.4193 61.2421 37.1441 35.0112 60.3988 53.0373 49.0117];
p=[65.9094 4.7869 19.8024 92.9458 58.7150 2.5256 30.0739 5.4808 79.6784 71.4252 54.0998 59.0927 21.8838 41.9776 52.0662 83.9952 66.3312 48.6364 85.4237 48.6713 27.9573 73.3884 96.9775 38.1866 24.6214 25.0278 2.8750 98.2827 80.4593 56.7850 39.4941 65.6003 99.3771 71.6628 11.1343 45.2816 69.5867 33.9626 92.2531 63.6166 93.2864 43.1661 30.7485 89.0138 2.7200 15.6575 95.9571 71.7325 31.3402 82.9815 80.9813 91.0163 64.6385 63.2399 12.7286 91.9783 62.7741 26.5009 95.1791 5.5744 3.0718 9.7170 52.2664 87.9877 40.8157 56.5710 60.2174 8.4300 39.7575 36.1435 25.2341 11.6948 12.1166 27.4533 27.3728 93.6720 19.4315 51.2361 15.6118 92.1493 93.0167 14.5384 87.2854 2.2232 72.4816 87.9799 39.3572 25.3966 12.0606 84.8313 66.3062 78.1866 36.4977 19.2294 2.0078 9.5056 33.6173 30.7822 51.1505 39.2739];
sim_in = [v, p];
sim_out = [7.1311 6.3588 6.0545 7.8257 9.1521 8.0623 7.0667 6.2499 6.0917 6.2498 7.5273 7.2557 6.3734 7.3573 8.4913 9.8310 8.9261 7.8193 10.0257 10.6941 10.6282 10.7414 12.1362 12.1442 11.7505 11.4088 10.1702 10.6450 10.8248 10.4919 10.7776 10.6827 10.0315 11.5522 10.4712 9.5101 10.7533 10.1794 11.1625 10.3909 13.2449 12.4087 11.7282 12.7822 11.4824 10.6570 12.2692 12.0873 11.6660 13.5195 15.6611 17.3295 16.0747 14.6372 13.5176 15.7546 15.6847 14.2223 13.8570 12.4838 11.1820 10.2803 11.2498 12.3825 12.6999 12.0127 12.5235 11.4221 11.6250 10.7953 10.4960 9.4175 8.6992 8.0898 7.8539 8.0031 7.7384 8.6275 8.1134 9.7540 11.1313 10.4081 10.5331 9.3326 10.0847 9.6961 8.9038 7.8016 7.2000 8.8101 8.4298 8.2227 7.2229 6.6039 5.6859 5.0770 5.2510 4.9641 5.2480 5.3237];
v_Datastore = arrayDatastore(v);
p_Datastore = arrayDatastore(p);
out_Datastore=arrayDatastore(sim_out);
trainDatastore = combine(v_Datastore, p_Datastore, out_Datastore);
% —————CREATE END TRAIN NETWORK——————
% Network architecture
numResponses = 1;
featureDimension = 1;
numHiddenUnits = 400;
maxEpochs = 400;
miniBatchSize = 300;
Networklayers = [sequenceInputLayer(featureDimension) …
lstmLayer(numHiddenUnits) …
dropoutLayer(0.02),…
fullyConnectedLayer(numResponses) …
regressionLayer
];
options = trainingOptions(‘adam’, …
‘MaxEpochs’,maxEpochs, …
‘MiniBatchSize’,miniBatchSize, …
‘GradientThreshold’,20, …
‘Shuffle’,’once’, …
‘Plots’,’training-progress’,…
‘LearnRateSchedule’,’piecewise’,…
‘LearnRateDropPeriod’,200,…
‘L2Regularization’,1e-3,…
‘LearnRateDropFactor’,0.5,…
‘Verbose’,0,…
‘ValidationData’,[{sim_in} {sim_out}]);
% ENTRENAMIENTO
net = trainnet(trainDatastore, Networklayers,options);
Falta un argumento en la llamada a la función pero no se cuál poner. Gracias.
There is a missing argument in the function call but I don’t know which one to put. Thank you.
Si pongo trainNetwork el error es:
If I put trainNetwork the error is:
Error using trainNetwork (line 191)
Invalid validation data. Sequence responses must have the same sequence length as the
corresponding predictors.
Error in miso_directo (line 52)
net = trainNetwork(trainDatastore,Networklayers,options);
Tengo dos entradas de 100 elementos y una salida de 100 elementos.
I have two inputs of 100 elements and one output of 100 elements.
Gracias. Thanks. Hola, el siguiente código arroja el siguiente error:
Hello, the following code throws the following error:
clc
clear
close all
A1 = 0.04;
A4 = 0.04;
B1 = 1.5e-4;
B4 = 1.5e-4;
Kp1 = 3.7E-6;
Kp4 = 3.7E-6;
g = 9.8;
v=[12.6101 1.0688 31.0125 37.5489 12.9138 71.4793 95.7939 32.9065 79.1094 67.4771 11.8518 72.6723 88.3776 1.0488 11.0924 37.6680 91.5542 99.8999 17.8789 18.0891 11.2040 61.0086 41.7771 26.3225 20.9668 19.5812 88.4935 63.5100 62.6202 66.1686 18.5314 62.9590 87.7691 18.6421 64.9118 88.5281 25.8011 59.0359 49.2004 84.0695 6.1159 74.2078 55.8971 43.5178 78.1925 40.2701 36.3657 66.2878 40.0230 18.6693 6.3752 25.4650 90.2795 98.2619 48.9268 15.3302 51.6550 99.3592 76.4943 96.6364 93.0582 24.4126 10.6547 41.5677 13.9861 75.7021 35.4622 45.5286 20.7342 73.9153 21.1334 77.0479 24.8867 61.7596 35.2314 72.5405 12.6051 18.8981 20.1926 36.6943 41.0350 23.3522 67.2367 95.7641 43.7348 80.5776 80.0207 99.5289 21.9686 33.5729 76.4718 75.9192 96.1664 57.4193 61.2421 37.1441 35.0112 60.3988 53.0373 49.0117];
p=[65.9094 4.7869 19.8024 92.9458 58.7150 2.5256 30.0739 5.4808 79.6784 71.4252 54.0998 59.0927 21.8838 41.9776 52.0662 83.9952 66.3312 48.6364 85.4237 48.6713 27.9573 73.3884 96.9775 38.1866 24.6214 25.0278 2.8750 98.2827 80.4593 56.7850 39.4941 65.6003 99.3771 71.6628 11.1343 45.2816 69.5867 33.9626 92.2531 63.6166 93.2864 43.1661 30.7485 89.0138 2.7200 15.6575 95.9571 71.7325 31.3402 82.9815 80.9813 91.0163 64.6385 63.2399 12.7286 91.9783 62.7741 26.5009 95.1791 5.5744 3.0718 9.7170 52.2664 87.9877 40.8157 56.5710 60.2174 8.4300 39.7575 36.1435 25.2341 11.6948 12.1166 27.4533 27.3728 93.6720 19.4315 51.2361 15.6118 92.1493 93.0167 14.5384 87.2854 2.2232 72.4816 87.9799 39.3572 25.3966 12.0606 84.8313 66.3062 78.1866 36.4977 19.2294 2.0078 9.5056 33.6173 30.7822 51.1505 39.2739];
sim_in = [v, p];
sim_out = [7.1311 6.3588 6.0545 7.8257 9.1521 8.0623 7.0667 6.2499 6.0917 6.2498 7.5273 7.2557 6.3734 7.3573 8.4913 9.8310 8.9261 7.8193 10.0257 10.6941 10.6282 10.7414 12.1362 12.1442 11.7505 11.4088 10.1702 10.6450 10.8248 10.4919 10.7776 10.6827 10.0315 11.5522 10.4712 9.5101 10.7533 10.1794 11.1625 10.3909 13.2449 12.4087 11.7282 12.7822 11.4824 10.6570 12.2692 12.0873 11.6660 13.5195 15.6611 17.3295 16.0747 14.6372 13.5176 15.7546 15.6847 14.2223 13.8570 12.4838 11.1820 10.2803 11.2498 12.3825 12.6999 12.0127 12.5235 11.4221 11.6250 10.7953 10.4960 9.4175 8.6992 8.0898 7.8539 8.0031 7.7384 8.6275 8.1134 9.7540 11.1313 10.4081 10.5331 9.3326 10.0847 9.6961 8.9038 7.8016 7.2000 8.8101 8.4298 8.2227 7.2229 6.6039 5.6859 5.0770 5.2510 4.9641 5.2480 5.3237];
v_Datastore = arrayDatastore(v);
p_Datastore = arrayDatastore(p);
out_Datastore=arrayDatastore(sim_out);
trainDatastore = combine(v_Datastore, p_Datastore, out_Datastore);
% —————CREATE END TRAIN NETWORK——————
% Network architecture
numResponses = 1;
featureDimension = 1;
numHiddenUnits = 400;
maxEpochs = 400;
miniBatchSize = 300;
Networklayers = [sequenceInputLayer(featureDimension) …
lstmLayer(numHiddenUnits) …
dropoutLayer(0.02),…
fullyConnectedLayer(numResponses) …
regressionLayer
];
options = trainingOptions(‘adam’, …
‘MaxEpochs’,maxEpochs, …
‘MiniBatchSize’,miniBatchSize, …
‘GradientThreshold’,20, …
‘Shuffle’,’once’, …
‘Plots’,’training-progress’,…
‘LearnRateSchedule’,’piecewise’,…
‘LearnRateDropPeriod’,200,…
‘L2Regularization’,1e-3,…
‘LearnRateDropFactor’,0.5,…
‘Verbose’,0,…
‘ValidationData’,[{sim_in} {sim_out}]);
% ENTRENAMIENTO
net = trainnet(trainDatastore, Networklayers,options);
Falta un argumento en la llamada a la función pero no se cuál poner. Gracias.
There is a missing argument in the function call but I don’t know which one to put. Thank you.
Si pongo trainNetwork el error es:
If I put trainNetwork the error is:
Error using trainNetwork (line 191)
Invalid validation data. Sequence responses must have the same sequence length as the
corresponding predictors.
Error in miso_directo (line 52)
net = trainNetwork(trainDatastore,Networklayers,options);
Tengo dos entradas de 100 elementos y una salida de 100 elementos.
I have two inputs of 100 elements and one output of 100 elements.
Gracias. Thanks. transferred MATLAB Answers — New Questions
Indexing of cell array and a vector
Hi guys, my problem has been raised before but with some differences.
I have a cell array of indexes, index. Its cells can be zero or vectors with several values. On the other hand I have a data vector, data. I need a cell array, out, that relates data to indexes, preferably without using a loop.
For example:
index = {[0], [0], [5], [0], [6, 7], [0], [0], [1], [0], [0], [0], [ 3]} ;
data = [100, 10, 20, 15, 11, 25, 200, 45];
Desired result:
out = {[0], [0], [11], [0], [25, 200], [0], [0], [100], [0], [0], [20]}
Can somebody help me?Hi guys, my problem has been raised before but with some differences.
I have a cell array of indexes, index. Its cells can be zero or vectors with several values. On the other hand I have a data vector, data. I need a cell array, out, that relates data to indexes, preferably without using a loop.
For example:
index = {[0], [0], [5], [0], [6, 7], [0], [0], [1], [0], [0], [0], [ 3]} ;
data = [100, 10, 20, 15, 11, 25, 200, 45];
Desired result:
out = {[0], [0], [11], [0], [25, 200], [0], [0], [100], [0], [0], [20]}
Can somebody help me? Hi guys, my problem has been raised before but with some differences.
I have a cell array of indexes, index. Its cells can be zero or vectors with several values. On the other hand I have a data vector, data. I need a cell array, out, that relates data to indexes, preferably without using a loop.
For example:
index = {[0], [0], [5], [0], [6, 7], [0], [0], [1], [0], [0], [0], [ 3]} ;
data = [100, 10, 20, 15, 11, 25, 200, 45];
Desired result:
out = {[0], [0], [11], [0], [25, 200], [0], [0], [100], [0], [0], [20]}
Can somebody help me? cell array, indexing MATLAB Answers — New Questions
Is it possible to export measurement reading of Signal Statistics in Simulink Scope block to workspace? If it is possible, then how?
Hello and thank you for you concern Sir. As mention above, I’m fully aware about the method on data logging from the scope display to workspace. However, the logging only record/export the simulation signal data to our workspace. Refer to image that i attached, the scope able to determine the Max, Min, Peak to peak, Median and RMS value for the simulation. These reading is in the Signal Statistics section if the scope display enable it from Tools>Measurement>Signal Statistics.
My motivation is to obtain the RMS value recorded in the scope and export it to workspace or save it to a file or etc. It is because I’m dealing with multiple/repitative simulations with different parameters just to observe the changes of the RMS value. Hence, is there any possible way to export the readings? or any possible way for me to obtain RMS value of the simulation.
Notes: I had try the RMS block in the simulink, however it did not provide the correct measurement. I think this happen due to my sample data if from discharging of battery model (DC current). Maybe, I’m not verry sure. Sorry.
Anyway, thank you in advance if someone able to help me on this. I really appriciate your concern Sir.Hello and thank you for you concern Sir. As mention above, I’m fully aware about the method on data logging from the scope display to workspace. However, the logging only record/export the simulation signal data to our workspace. Refer to image that i attached, the scope able to determine the Max, Min, Peak to peak, Median and RMS value for the simulation. These reading is in the Signal Statistics section if the scope display enable it from Tools>Measurement>Signal Statistics.
My motivation is to obtain the RMS value recorded in the scope and export it to workspace or save it to a file or etc. It is because I’m dealing with multiple/repitative simulations with different parameters just to observe the changes of the RMS value. Hence, is there any possible way to export the readings? or any possible way for me to obtain RMS value of the simulation.
Notes: I had try the RMS block in the simulink, however it did not provide the correct measurement. I think this happen due to my sample data if from discharging of battery model (DC current). Maybe, I’m not verry sure. Sorry.
Anyway, thank you in advance if someone able to help me on this. I really appriciate your concern Sir. Hello and thank you for you concern Sir. As mention above, I’m fully aware about the method on data logging from the scope display to workspace. However, the logging only record/export the simulation signal data to our workspace. Refer to image that i attached, the scope able to determine the Max, Min, Peak to peak, Median and RMS value for the simulation. These reading is in the Signal Statistics section if the scope display enable it from Tools>Measurement>Signal Statistics.
My motivation is to obtain the RMS value recorded in the scope and export it to workspace or save it to a file or etc. It is because I’m dealing with multiple/repitative simulations with different parameters just to observe the changes of the RMS value. Hence, is there any possible way to export the readings? or any possible way for me to obtain RMS value of the simulation.
Notes: I had try the RMS block in the simulink, however it did not provide the correct measurement. I think this happen due to my sample data if from discharging of battery model (DC current). Maybe, I’m not verry sure. Sorry.
Anyway, thank you in advance if someone able to help me on this. I really appriciate your concern Sir. simulink, scope block, signal statistics, rms value MATLAB Answers — New Questions
Comparison of Crossover Methods: ‘crossoverheuristic’ vs ‘crossoverintermediate’ vs ‘crossoverarithmetic’
How is ‘crossoverheuristic’ different from ‘crossoverintermediate’?
Is that ‘crossoverheuristic’ always take ratio greater than 1, i.e., the offspring will always be much far from the parent with lower fitness compared to the parent with higher fitness?
Is ‘crossoverheuristic’ a special case of ‘crossoverintermediate’?
Should the ratio be always scalar in ‘crossoverheuristic’?
Is there any issue in setting the ratio to greater than 1 for ‘crossoverintermediate’ over a problem with linear constraints and bounds?
How is ‘crossoverarithmetic’ different from ‘crossoverintermediate’?How is ‘crossoverheuristic’ different from ‘crossoverintermediate’?
Is that ‘crossoverheuristic’ always take ratio greater than 1, i.e., the offspring will always be much far from the parent with lower fitness compared to the parent with higher fitness?
Is ‘crossoverheuristic’ a special case of ‘crossoverintermediate’?
Should the ratio be always scalar in ‘crossoverheuristic’?
Is there any issue in setting the ratio to greater than 1 for ‘crossoverintermediate’ over a problem with linear constraints and bounds?
How is ‘crossoverarithmetic’ different from ‘crossoverintermediate’? How is ‘crossoverheuristic’ different from ‘crossoverintermediate’?
Is that ‘crossoverheuristic’ always take ratio greater than 1, i.e., the offspring will always be much far from the parent with lower fitness compared to the parent with higher fitness?
Is ‘crossoverheuristic’ a special case of ‘crossoverintermediate’?
Should the ratio be always scalar in ‘crossoverheuristic’?
Is there any issue in setting the ratio to greater than 1 for ‘crossoverintermediate’ over a problem with linear constraints and bounds?
How is ‘crossoverarithmetic’ different from ‘crossoverintermediate’? ga, gamultiobj, crossover, genetic algorithm MATLAB Answers — New Questions
How to save entire MATLAB workspace as a JSON file?
Hi everyone, I need to export my MATLAB workspace as a JSON file.
From what I can see, the standard save command wouldn’t be useful here.
And the jsonencode help doesn’t tell you how to save the entire workspace as a JSON file:
Create JSON-formatted text from structured MATLAB data – MATLAB jsonencode – MathWorks United Kingdom
Any help on how to achieve this would be much appreciatedHi everyone, I need to export my MATLAB workspace as a JSON file.
From what I can see, the standard save command wouldn’t be useful here.
And the jsonencode help doesn’t tell you how to save the entire workspace as a JSON file:
Create JSON-formatted text from structured MATLAB data – MATLAB jsonencode – MathWorks United Kingdom
Any help on how to achieve this would be much appreciated Hi everyone, I need to export my MATLAB workspace as a JSON file.
From what I can see, the standard save command wouldn’t be useful here.
And the jsonencode help doesn’t tell you how to save the entire workspace as a JSON file:
Create JSON-formatted text from structured MATLAB data – MATLAB jsonencode – MathWorks United Kingdom
Any help on how to achieve this would be much appreciated json MATLAB Answers — New Questions
i am trying to run biped robot and it is giving following error: Error using rlRepresentation (line 70) rlRepresentation will be removed in a future release. Unable to automat
i am trying to run biped robot and it is giving following error:
Error using rlRepresentation (line 70) rlRepresentation will be removed in a future release. Unable to automatically convert rlRepresentation to new representation object. Use the new representation objects rlValueRepresentation, rlQValueRepresentation, rlDeterministicActorRepresentation, or rlStochasticActorRepresentation instead.i am trying to run biped robot and it is giving following error:
Error using rlRepresentation (line 70) rlRepresentation will be removed in a future release. Unable to automatically convert rlRepresentation to new representation object. Use the new representation objects rlValueRepresentation, rlQValueRepresentation, rlDeterministicActorRepresentation, or rlStochasticActorRepresentation instead. i am trying to run biped robot and it is giving following error:
Error using rlRepresentation (line 70) rlRepresentation will be removed in a future release. Unable to automatically convert rlRepresentation to new representation object. Use the new representation objects rlValueRepresentation, rlQValueRepresentation, rlDeterministicActorRepresentation, or rlStochasticActorRepresentation instead. rl represetation MATLAB Answers — New Questions
Is the state variable x a column vector or a row vector?
In a state space equation such as xdot=Ax+Bu, if the system has only two state variables, x1 and x2, shouldn’t the x matrix be just a 2*1 matrix? Suppose I control the system by means of an LQR linear controller and get the corresponding results for the state variables x1 and x2, at this point I want to represent them by means of an image. At this point I just want to know the representation of x1 in the image, is it correct to use the plot(t,x(:,1)); statement. If the plotting is correct at this point, but x(:,1) is queried in the help as referring to the elements of all rows in the first column of the matrix, this suggests that the value of x1 is stored in the first column of the x matrix, but as stated at the beginning the x matrix should be a 2 row, 1 column matrix.
About why the plot(t,x(:,1)); statement is used to get the image of x1 is something I can’t understand at the moment.
Hope someone can help me with this query, thanks a lot!!!!
Translated with www.DeepL.com/Translator (free version)
clc;clear;close all;
%% 定义参数
g=10;
d=1;
%% 定义矩阵
A=[0 1;g/d 0];
B=[0;1];
C = [1, 0];
D = 0;
%% 建立状态空间方程表达式
sys = ss(A,B,C,D);
%% 定义初始状态
z0=[pi/20;0];
%% 定义权重系数,求K
q1=[100 0;0 1];
r1=1;
[K1, z, l] = lqr (sys, q1, r1);
q2=[1 0;0 100];
r2=1;
[K2, z, l] = lqr (sys, q2, r2);
q3=[1 0;0 1];
r3=100;
[K3, z, l] = lqr (sys, q3, r3);
%% 定义闭环系统
sys_cl1=ss(A-B*K1,[0;0],C,D);
sys_cl2=ss(A-B*K2,[0;0],C,D);
sys_cl3=ss(A-B*K3,[0;0],C,D);
%% 仿真
%% 对初始条件的响应
t=0:0.01:5;
[y1,t,z1]=initial(sys_cl1,z0,t);
[y2,t,z2]=initial(sys_cl2,z0,t);
[y3,t,z3]=initial(sys_cl3,z0,t);
%% 绘图
%% 状态变量1
subplot(3,1,1);
plot(t,z1(:,1));
hold on;
plot(t,z2(:,1));
hold on;
plot(t,z3(:,1));
legend(‘z1_1′,’z1_2′,’z1_3’);
grid on;
hold off;
%% 状态变量2
subplot(3,1,2);
plot(t,z1(:,2));
hold on;
plot(t,z2(:,2));
hold on;
plot(t,z3(:,2));
legend(‘z2_1′,’z2_2′,’z2_3’);
grid on;
hold off;
%% 系统输入
subplot(3,1,3);
plot(t,-K1*z1′);
hold on;
plot(t,-K2*z3′);
hold on;
plot(t,-K3*z3′);
legend(‘u_1′,’u_2′,’u_3’);
grid on;
hold off;In a state space equation such as xdot=Ax+Bu, if the system has only two state variables, x1 and x2, shouldn’t the x matrix be just a 2*1 matrix? Suppose I control the system by means of an LQR linear controller and get the corresponding results for the state variables x1 and x2, at this point I want to represent them by means of an image. At this point I just want to know the representation of x1 in the image, is it correct to use the plot(t,x(:,1)); statement. If the plotting is correct at this point, but x(:,1) is queried in the help as referring to the elements of all rows in the first column of the matrix, this suggests that the value of x1 is stored in the first column of the x matrix, but as stated at the beginning the x matrix should be a 2 row, 1 column matrix.
About why the plot(t,x(:,1)); statement is used to get the image of x1 is something I can’t understand at the moment.
Hope someone can help me with this query, thanks a lot!!!!
Translated with www.DeepL.com/Translator (free version)
clc;clear;close all;
%% 定义参数
g=10;
d=1;
%% 定义矩阵
A=[0 1;g/d 0];
B=[0;1];
C = [1, 0];
D = 0;
%% 建立状态空间方程表达式
sys = ss(A,B,C,D);
%% 定义初始状态
z0=[pi/20;0];
%% 定义权重系数,求K
q1=[100 0;0 1];
r1=1;
[K1, z, l] = lqr (sys, q1, r1);
q2=[1 0;0 100];
r2=1;
[K2, z, l] = lqr (sys, q2, r2);
q3=[1 0;0 1];
r3=100;
[K3, z, l] = lqr (sys, q3, r3);
%% 定义闭环系统
sys_cl1=ss(A-B*K1,[0;0],C,D);
sys_cl2=ss(A-B*K2,[0;0],C,D);
sys_cl3=ss(A-B*K3,[0;0],C,D);
%% 仿真
%% 对初始条件的响应
t=0:0.01:5;
[y1,t,z1]=initial(sys_cl1,z0,t);
[y2,t,z2]=initial(sys_cl2,z0,t);
[y3,t,z3]=initial(sys_cl3,z0,t);
%% 绘图
%% 状态变量1
subplot(3,1,1);
plot(t,z1(:,1));
hold on;
plot(t,z2(:,1));
hold on;
plot(t,z3(:,1));
legend(‘z1_1′,’z1_2′,’z1_3’);
grid on;
hold off;
%% 状态变量2
subplot(3,1,2);
plot(t,z1(:,2));
hold on;
plot(t,z2(:,2));
hold on;
plot(t,z3(:,2));
legend(‘z2_1′,’z2_2′,’z2_3’);
grid on;
hold off;
%% 系统输入
subplot(3,1,3);
plot(t,-K1*z1′);
hold on;
plot(t,-K2*z3′);
hold on;
plot(t,-K3*z3′);
legend(‘u_1′,’u_2′,’u_3’);
grid on;
hold off; In a state space equation such as xdot=Ax+Bu, if the system has only two state variables, x1 and x2, shouldn’t the x matrix be just a 2*1 matrix? Suppose I control the system by means of an LQR linear controller and get the corresponding results for the state variables x1 and x2, at this point I want to represent them by means of an image. At this point I just want to know the representation of x1 in the image, is it correct to use the plot(t,x(:,1)); statement. If the plotting is correct at this point, but x(:,1) is queried in the help as referring to the elements of all rows in the first column of the matrix, this suggests that the value of x1 is stored in the first column of the x matrix, but as stated at the beginning the x matrix should be a 2 row, 1 column matrix.
About why the plot(t,x(:,1)); statement is used to get the image of x1 is something I can’t understand at the moment.
Hope someone can help me with this query, thanks a lot!!!!
Translated with www.DeepL.com/Translator (free version)
clc;clear;close all;
%% 定义参数
g=10;
d=1;
%% 定义矩阵
A=[0 1;g/d 0];
B=[0;1];
C = [1, 0];
D = 0;
%% 建立状态空间方程表达式
sys = ss(A,B,C,D);
%% 定义初始状态
z0=[pi/20;0];
%% 定义权重系数,求K
q1=[100 0;0 1];
r1=1;
[K1, z, l] = lqr (sys, q1, r1);
q2=[1 0;0 100];
r2=1;
[K2, z, l] = lqr (sys, q2, r2);
q3=[1 0;0 1];
r3=100;
[K3, z, l] = lqr (sys, q3, r3);
%% 定义闭环系统
sys_cl1=ss(A-B*K1,[0;0],C,D);
sys_cl2=ss(A-B*K2,[0;0],C,D);
sys_cl3=ss(A-B*K3,[0;0],C,D);
%% 仿真
%% 对初始条件的响应
t=0:0.01:5;
[y1,t,z1]=initial(sys_cl1,z0,t);
[y2,t,z2]=initial(sys_cl2,z0,t);
[y3,t,z3]=initial(sys_cl3,z0,t);
%% 绘图
%% 状态变量1
subplot(3,1,1);
plot(t,z1(:,1));
hold on;
plot(t,z2(:,1));
hold on;
plot(t,z3(:,1));
legend(‘z1_1′,’z1_2′,’z1_3’);
grid on;
hold off;
%% 状态变量2
subplot(3,1,2);
plot(t,z1(:,2));
hold on;
plot(t,z2(:,2));
hold on;
plot(t,z3(:,2));
legend(‘z2_1′,’z2_2′,’z2_3’);
grid on;
hold off;
%% 系统输入
subplot(3,1,3);
plot(t,-K1*z1′);
hold on;
plot(t,-K2*z3′);
hold on;
plot(t,-K3*z3′);
legend(‘u_1′,’u_2′,’u_3’);
grid on;
hold off; state space, vector MATLAB Answers — New Questions
Simulink error: Size of data type ‘CAN_MESSAGE’ has not been set
Hello everyone, I am working on a model using CAN bus to receive data.But when building the model it pops out an ERROR:"Size of data type ‘CAN_MESSAGE’ has not been set" and I can’t find solution anywhere.
My environment: Matlab2018b, Visual Studio 2015, Freescale s32ds v1.0. I am coding for a VCU which contains a MPC5744 as CPU (perhaps)
And I have asked the guy from the VCU company, he said the model seems to be fine, the problem may be about my environment or something else…
Sincere appreciation for any advice!!Hello everyone, I am working on a model using CAN bus to receive data.But when building the model it pops out an ERROR:"Size of data type ‘CAN_MESSAGE’ has not been set" and I can’t find solution anywhere.
My environment: Matlab2018b, Visual Studio 2015, Freescale s32ds v1.0. I am coding for a VCU which contains a MPC5744 as CPU (perhaps)
And I have asked the guy from the VCU company, he said the model seems to be fine, the problem may be about my environment or something else…
Sincere appreciation for any advice!! Hello everyone, I am working on a model using CAN bus to receive data.But when building the model it pops out an ERROR:"Size of data type ‘CAN_MESSAGE’ has not been set" and I can’t find solution anywhere.
My environment: Matlab2018b, Visual Studio 2015, Freescale s32ds v1.0. I am coding for a VCU which contains a MPC5744 as CPU (perhaps)
And I have asked the guy from the VCU company, he said the model seems to be fine, the problem may be about my environment or something else…
Sincere appreciation for any advice!! can communication, simulink vehicle network toolbox MATLAB Answers — New Questions
Plot intersection between two surfaces and a plane.
I would like to plot the xy intersection of two surfaces coming from
surf command and a plane from the patch command.
I tried with the contourf, but it seems to be not possible.
Can this be done?I would like to plot the xy intersection of two surfaces coming from
surf command and a plane from the patch command.
I tried with the contourf, but it seems to be not possible.
Can this be done? I would like to plot the xy intersection of two surfaces coming from
surf command and a plane from the patch command.
I tried with the contourf, but it seems to be not possible.
Can this be done? plane, intersection, xyplot, double surface MATLAB Answers — New Questions
PPO | RL | Training for 10000 rounds still doesn’t get effective training, and the reward curve is very flat
With reinforcement learning using PPO algorithm, the Episode reward will oscillate in a wide range all the time, and the average reward curve will change very little.
My question is whether the Episode reward value for such oscillations is due to the large difference in the initial random environment settings, the large difference in the rewards obtained per episode, or the unreasonable parameter settings of the training.
The initial environment generates random locations through distance and angle variables
angle=-4*pi/8+sign(2*rand(1)-1)*rand(1)*pi/8;
dist=10000+rand(1)*4000;
The current agent settings and training settings are as follows:
actorOpts = rlOptimizerOptions(LearnRate=1e-4,GradientThreshold=1);
criticOpts = rlOptimizerOptions(LearnRate=1e-4,GradientThreshold=1);
agentOpts = rlPPOAgentOptions(…
ActorOptimizerOptions=actorOpts,…
CriticOptimizerOptions=criticOpts,…
ExperienceHorizon=2500,…
ClipFactor=0.1,…
EntropyLossWeight=0.02,…
MiniBatchSize=256,…
NumEpoch=9,…
AdvantageEstimateMethod="gae",…
GAEFactor=0.95,…
SampleTime=0.01,…
DiscountFactor=0.99);
trainOpts = rlTrainingOptions(…
‘MaxEpisodes’,100000, …
‘MaxStepsPerEpisode’,2500, …
‘Verbose’,false, …
‘StopTrainingCriteria’,"AverageReward",…
‘StopTrainingValue’,1000,…
‘ScoreAveragingWindowLength’,1000);
trainOpts.UseParallel = true;
trainOpts.ParallelizationOptions.StepsUntilDataIsSent = 2^11;With reinforcement learning using PPO algorithm, the Episode reward will oscillate in a wide range all the time, and the average reward curve will change very little.
My question is whether the Episode reward value for such oscillations is due to the large difference in the initial random environment settings, the large difference in the rewards obtained per episode, or the unreasonable parameter settings of the training.
The initial environment generates random locations through distance and angle variables
angle=-4*pi/8+sign(2*rand(1)-1)*rand(1)*pi/8;
dist=10000+rand(1)*4000;
The current agent settings and training settings are as follows:
actorOpts = rlOptimizerOptions(LearnRate=1e-4,GradientThreshold=1);
criticOpts = rlOptimizerOptions(LearnRate=1e-4,GradientThreshold=1);
agentOpts = rlPPOAgentOptions(…
ActorOptimizerOptions=actorOpts,…
CriticOptimizerOptions=criticOpts,…
ExperienceHorizon=2500,…
ClipFactor=0.1,…
EntropyLossWeight=0.02,…
MiniBatchSize=256,…
NumEpoch=9,…
AdvantageEstimateMethod="gae",…
GAEFactor=0.95,…
SampleTime=0.01,…
DiscountFactor=0.99);
trainOpts = rlTrainingOptions(…
‘MaxEpisodes’,100000, …
‘MaxStepsPerEpisode’,2500, …
‘Verbose’,false, …
‘StopTrainingCriteria’,"AverageReward",…
‘StopTrainingValue’,1000,…
‘ScoreAveragingWindowLength’,1000);
trainOpts.UseParallel = true;
trainOpts.ParallelizationOptions.StepsUntilDataIsSent = 2^11; With reinforcement learning using PPO algorithm, the Episode reward will oscillate in a wide range all the time, and the average reward curve will change very little.
My question is whether the Episode reward value for such oscillations is due to the large difference in the initial random environment settings, the large difference in the rewards obtained per episode, or the unreasonable parameter settings of the training.
The initial environment generates random locations through distance and angle variables
angle=-4*pi/8+sign(2*rand(1)-1)*rand(1)*pi/8;
dist=10000+rand(1)*4000;
The current agent settings and training settings are as follows:
actorOpts = rlOptimizerOptions(LearnRate=1e-4,GradientThreshold=1);
criticOpts = rlOptimizerOptions(LearnRate=1e-4,GradientThreshold=1);
agentOpts = rlPPOAgentOptions(…
ActorOptimizerOptions=actorOpts,…
CriticOptimizerOptions=criticOpts,…
ExperienceHorizon=2500,…
ClipFactor=0.1,…
EntropyLossWeight=0.02,…
MiniBatchSize=256,…
NumEpoch=9,…
AdvantageEstimateMethod="gae",…
GAEFactor=0.95,…
SampleTime=0.01,…
DiscountFactor=0.99);
trainOpts = rlTrainingOptions(…
‘MaxEpisodes’,100000, …
‘MaxStepsPerEpisode’,2500, …
‘Verbose’,false, …
‘StopTrainingCriteria’,"AverageReward",…
‘StopTrainingValue’,1000,…
‘ScoreAveragingWindowLength’,1000);
trainOpts.UseParallel = true;
trainOpts.ParallelizationOptions.StepsUntilDataIsSent = 2^11; ppo, reinforcement learning, reward curve MATLAB Answers — New Questions
Issues with Converting Binary Array to Decimal Value in MATLAB DLL for C++ Integration
Hello everyone,
I want to convert a binary array to a decimal value. When using MATLAB functions like bi2de and bit2int and then compiling them into a DLL using the library compiler, calling them from C++ results in errors indicating that the library could not be initialized. Is there an alternative MATLAB function that can be compiled into a DLL and called from C++ without issues?
I have also tried using a combination of bin2dec(num2str()), which loads the DLL correctly after compilation, but the execution results are incorrect. The result is displayed as a huge decimal number. What could be the reason for this?Hello everyone,
I want to convert a binary array to a decimal value. When using MATLAB functions like bi2de and bit2int and then compiling them into a DLL using the library compiler, calling them from C++ results in errors indicating that the library could not be initialized. Is there an alternative MATLAB function that can be compiled into a DLL and called from C++ without issues?
I have also tried using a combination of bin2dec(num2str()), which loads the DLL correctly after compilation, but the execution results are incorrect. The result is displayed as a huge decimal number. What could be the reason for this? Hello everyone,
I want to convert a binary array to a decimal value. When using MATLAB functions like bi2de and bit2int and then compiling them into a DLL using the library compiler, calling them from C++ results in errors indicating that the library could not be initialized. Is there an alternative MATLAB function that can be compiled into a DLL and called from C++ without issues?
I have also tried using a combination of bin2dec(num2str()), which loads the DLL correctly after compilation, but the execution results are incorrect. The result is displayed as a huge decimal number. What could be the reason for this? binary array, decimal value, matlab compiler, dll MATLAB Answers — New Questions
Calculate the volume of shape descibed by 3d points.
Given a set of 3d data points, without using the Image Processing Toolbox, what is the best method for working put the volume of the object described by the points?Given a set of 3d data points, without using the Image Processing Toolbox, what is the best method for working put the volume of the object described by the points? Given a set of 3d data points, without using the Image Processing Toolbox, what is the best method for working put the volume of the object described by the points? convex hull, convhull, trisurf MATLAB Answers — New Questions
finding 4 neighbor of pixel in grayscale image.
i am trying to find the 4 neighbor of pixel x0,y0 in grayscale image but i getting empty x,y . her is the code i am using
function [x,y]= neighbours(image,x0,y0,thres)
image=double(image);
interest = image(x0,y0);
pixel =zeros(size(image));
pixel(x0,y0)=1;
x=[];
y=[];
up= image(conv2(pixel,[0 1 0; 0 0 0; 0 0 0],’same’)>0);
if abs(up- interest)<=thres
if isempty(up)~=1
x(1)=x0;
y(1)=y0-1;
end
end
down= image(conv2(pixel,[0 0 0; 0 0 0; 0 1 0],’same’)>0);
if abs(down- interest)<=thres
if isempty(down)~=1
x(2)=x0;
y(2)=y0+1;
end
end
left= image(conv2(pixel,[0 0 0; 1 0 0; 0 0 0],’same’)>0);
if abs(left- interest)<=thres
if isempty(left)~=1
x(3)=x0-1;
y(3)=y0;
end
end
right= image(conv2(pixel,[0 0 0; 0 0 1; 0 0 0],’same’)>0);
if abs(right- interest)<=thres
if isempty(right)~=1
x(4)=x0+1;
y(4)=y0;
end
end
endi am trying to find the 4 neighbor of pixel x0,y0 in grayscale image but i getting empty x,y . her is the code i am using
function [x,y]= neighbours(image,x0,y0,thres)
image=double(image);
interest = image(x0,y0);
pixel =zeros(size(image));
pixel(x0,y0)=1;
x=[];
y=[];
up= image(conv2(pixel,[0 1 0; 0 0 0; 0 0 0],’same’)>0);
if abs(up- interest)<=thres
if isempty(up)~=1
x(1)=x0;
y(1)=y0-1;
end
end
down= image(conv2(pixel,[0 0 0; 0 0 0; 0 1 0],’same’)>0);
if abs(down- interest)<=thres
if isempty(down)~=1
x(2)=x0;
y(2)=y0+1;
end
end
left= image(conv2(pixel,[0 0 0; 1 0 0; 0 0 0],’same’)>0);
if abs(left- interest)<=thres
if isempty(left)~=1
x(3)=x0-1;
y(3)=y0;
end
end
right= image(conv2(pixel,[0 0 0; 0 0 1; 0 0 0],’same’)>0);
if abs(right- interest)<=thres
if isempty(right)~=1
x(4)=x0+1;
y(4)=y0;
end
end
end i am trying to find the 4 neighbor of pixel x0,y0 in grayscale image but i getting empty x,y . her is the code i am using
function [x,y]= neighbours(image,x0,y0,thres)
image=double(image);
interest = image(x0,y0);
pixel =zeros(size(image));
pixel(x0,y0)=1;
x=[];
y=[];
up= image(conv2(pixel,[0 1 0; 0 0 0; 0 0 0],’same’)>0);
if abs(up- interest)<=thres
if isempty(up)~=1
x(1)=x0;
y(1)=y0-1;
end
end
down= image(conv2(pixel,[0 0 0; 0 0 0; 0 1 0],’same’)>0);
if abs(down- interest)<=thres
if isempty(down)~=1
x(2)=x0;
y(2)=y0+1;
end
end
left= image(conv2(pixel,[0 0 0; 1 0 0; 0 0 0],’same’)>0);
if abs(left- interest)<=thres
if isempty(left)~=1
x(3)=x0-1;
y(3)=y0;
end
end
right= image(conv2(pixel,[0 0 0; 0 0 1; 0 0 0],’same’)>0);
if abs(right- interest)<=thres
if isempty(right)~=1
x(4)=x0+1;
y(4)=y0;
end
end
end image segmentation, image processing, image analysis, matlab, digital image processing MATLAB Answers — New Questions
i have made a code which finds a specific value ‘no’ from the excel sheet but it does the job one by one. i want to automate it so it gives all values with ‘no’ at once.
this is the code i’m using.
data = readtable(‘FINALconvergencecheck_ksst.xlsx’);
data.Properties.VariableNames(1) = "an6cd";
data.Properties.VariableNames(3) = "an6cl";
data.Properties.VariableNames(5) = "an6cm";
data.Properties.VariableNames(7) = "ap0cd";
data.Properties.VariableNames(9) = "ap0cl";
data.Properties.VariableNames(11) = "ap0cm";
data.Properties.VariableNames(13) = "ap3cd";
data.Properties.VariableNames(15) = "ap3cl";
data.Properties.VariableNames(17) = "ap3cm";
data.Properties.VariableNames(19) = "ap7cd";
data.Properties.VariableNames(21) = "ap7cl";
data.Properties.VariableNames(23) = "ap7cm";
data.Properties.VariableNames(25) = "ap10cd";
data.Properties.VariableNames(27) = "ap10cl";
data.Properties.VariableNames(29) = "ap10cm";
data.Properties.VariableNames(31) = "ap12cd";
data.Properties.VariableNames(33) = "ap12cl";
data.Properties.VariableNames(35) = "ap12cm";
data.Properties.VariableNames(37) = "ap14cd";
data.Properties.VariableNames(39) = "ap14cl";
data.Properties.VariableNames(41) = "ap14cm";
data.Properties.VariableNames(43) = "ap15cd";
data.Properties.VariableNames(45) = "ap15cl";
data.Properties.VariableNames(47) = "ap15cm";
data.Properties.VariableNames(49) = "ap17cd";
data.Properties.VariableNames(51) = "ap17cl";
data.Properties.VariableNames(53) = "ap17cm";
data.Properties.VariableNames(2) = "an6cd_r";
data.Properties.VariableNames(4) = "an6cl_r";
data.Properties.VariableNames(6) = "an6cm_r";
data.Properties.VariableNames(8) = "ap0cd_r";
data.Properties.VariableNames(10) = "ap0cl_r";
data.Properties.VariableNames(12) = "ap0cm_r";
data.Properties.VariableNames(14) = "ap3cd_r";
data.Properties.VariableNames(16) = "ap3cl_r";
data.Properties.VariableNames(18) = "ap3cm_r";
data.Properties.VariableNames(20) = "ap7cd_r";
data.Properties.VariableNames(22) = "ap7cl_r";
data.Properties.VariableNames(24) = "ap7cm_r";
data.Properties.VariableNames(26) = "ap10cd_r";
data.Properties.VariableNames(28) = "ap10cl_r";
data.Properties.VariableNames(30) = "ap10cm_r";
data.Properties.VariableNames(32) = "ap12cd_r";
data.Properties.VariableNames(34) = "ap12cl_r";
data.Properties.VariableNames(36) = "ap12cm_r";
data.Properties.VariableNames(38) = "ap14cd_r";
data.Properties.VariableNames(40) = "ap14cl_r";
data.Properties.VariableNames(42) = "ap14cm_r";
data.Properties.VariableNames(44) = "ap15cd_r";
data.Properties.VariableNames(46) = "ap15cl_r";
data.Properties.VariableNames(48) = "ap15cm_r";
data.Properties.VariableNames(50) = "ap17cd_r";
data.Properties.VariableNames(52) = "ap17cl_r";
data.Properties.VariableNames(54) = "ap17cm_r";
display = find(data.ap10cl_r=="no");
k=display;
k1=string(k);
switch k1
case "yes"
disp(‘convereged’)
case "no"
disp(‘not convereged’)
end
here, i have to change the coulum again and again. i want to automate it in a way that it gives all the values where ‘no’ is at once.
kindly help.this is the code i’m using.
data = readtable(‘FINALconvergencecheck_ksst.xlsx’);
data.Properties.VariableNames(1) = "an6cd";
data.Properties.VariableNames(3) = "an6cl";
data.Properties.VariableNames(5) = "an6cm";
data.Properties.VariableNames(7) = "ap0cd";
data.Properties.VariableNames(9) = "ap0cl";
data.Properties.VariableNames(11) = "ap0cm";
data.Properties.VariableNames(13) = "ap3cd";
data.Properties.VariableNames(15) = "ap3cl";
data.Properties.VariableNames(17) = "ap3cm";
data.Properties.VariableNames(19) = "ap7cd";
data.Properties.VariableNames(21) = "ap7cl";
data.Properties.VariableNames(23) = "ap7cm";
data.Properties.VariableNames(25) = "ap10cd";
data.Properties.VariableNames(27) = "ap10cl";
data.Properties.VariableNames(29) = "ap10cm";
data.Properties.VariableNames(31) = "ap12cd";
data.Properties.VariableNames(33) = "ap12cl";
data.Properties.VariableNames(35) = "ap12cm";
data.Properties.VariableNames(37) = "ap14cd";
data.Properties.VariableNames(39) = "ap14cl";
data.Properties.VariableNames(41) = "ap14cm";
data.Properties.VariableNames(43) = "ap15cd";
data.Properties.VariableNames(45) = "ap15cl";
data.Properties.VariableNames(47) = "ap15cm";
data.Properties.VariableNames(49) = "ap17cd";
data.Properties.VariableNames(51) = "ap17cl";
data.Properties.VariableNames(53) = "ap17cm";
data.Properties.VariableNames(2) = "an6cd_r";
data.Properties.VariableNames(4) = "an6cl_r";
data.Properties.VariableNames(6) = "an6cm_r";
data.Properties.VariableNames(8) = "ap0cd_r";
data.Properties.VariableNames(10) = "ap0cl_r";
data.Properties.VariableNames(12) = "ap0cm_r";
data.Properties.VariableNames(14) = "ap3cd_r";
data.Properties.VariableNames(16) = "ap3cl_r";
data.Properties.VariableNames(18) = "ap3cm_r";
data.Properties.VariableNames(20) = "ap7cd_r";
data.Properties.VariableNames(22) = "ap7cl_r";
data.Properties.VariableNames(24) = "ap7cm_r";
data.Properties.VariableNames(26) = "ap10cd_r";
data.Properties.VariableNames(28) = "ap10cl_r";
data.Properties.VariableNames(30) = "ap10cm_r";
data.Properties.VariableNames(32) = "ap12cd_r";
data.Properties.VariableNames(34) = "ap12cl_r";
data.Properties.VariableNames(36) = "ap12cm_r";
data.Properties.VariableNames(38) = "ap14cd_r";
data.Properties.VariableNames(40) = "ap14cl_r";
data.Properties.VariableNames(42) = "ap14cm_r";
data.Properties.VariableNames(44) = "ap15cd_r";
data.Properties.VariableNames(46) = "ap15cl_r";
data.Properties.VariableNames(48) = "ap15cm_r";
data.Properties.VariableNames(50) = "ap17cd_r";
data.Properties.VariableNames(52) = "ap17cl_r";
data.Properties.VariableNames(54) = "ap17cm_r";
display = find(data.ap10cl_r=="no");
k=display;
k1=string(k);
switch k1
case "yes"
disp(‘convereged’)
case "no"
disp(‘not convereged’)
end
here, i have to change the coulum again and again. i want to automate it in a way that it gives all the values where ‘no’ is at once.
kindly help. this is the code i’m using.
data = readtable(‘FINALconvergencecheck_ksst.xlsx’);
data.Properties.VariableNames(1) = "an6cd";
data.Properties.VariableNames(3) = "an6cl";
data.Properties.VariableNames(5) = "an6cm";
data.Properties.VariableNames(7) = "ap0cd";
data.Properties.VariableNames(9) = "ap0cl";
data.Properties.VariableNames(11) = "ap0cm";
data.Properties.VariableNames(13) = "ap3cd";
data.Properties.VariableNames(15) = "ap3cl";
data.Properties.VariableNames(17) = "ap3cm";
data.Properties.VariableNames(19) = "ap7cd";
data.Properties.VariableNames(21) = "ap7cl";
data.Properties.VariableNames(23) = "ap7cm";
data.Properties.VariableNames(25) = "ap10cd";
data.Properties.VariableNames(27) = "ap10cl";
data.Properties.VariableNames(29) = "ap10cm";
data.Properties.VariableNames(31) = "ap12cd";
data.Properties.VariableNames(33) = "ap12cl";
data.Properties.VariableNames(35) = "ap12cm";
data.Properties.VariableNames(37) = "ap14cd";
data.Properties.VariableNames(39) = "ap14cl";
data.Properties.VariableNames(41) = "ap14cm";
data.Properties.VariableNames(43) = "ap15cd";
data.Properties.VariableNames(45) = "ap15cl";
data.Properties.VariableNames(47) = "ap15cm";
data.Properties.VariableNames(49) = "ap17cd";
data.Properties.VariableNames(51) = "ap17cl";
data.Properties.VariableNames(53) = "ap17cm";
data.Properties.VariableNames(2) = "an6cd_r";
data.Properties.VariableNames(4) = "an6cl_r";
data.Properties.VariableNames(6) = "an6cm_r";
data.Properties.VariableNames(8) = "ap0cd_r";
data.Properties.VariableNames(10) = "ap0cl_r";
data.Properties.VariableNames(12) = "ap0cm_r";
data.Properties.VariableNames(14) = "ap3cd_r";
data.Properties.VariableNames(16) = "ap3cl_r";
data.Properties.VariableNames(18) = "ap3cm_r";
data.Properties.VariableNames(20) = "ap7cd_r";
data.Properties.VariableNames(22) = "ap7cl_r";
data.Properties.VariableNames(24) = "ap7cm_r";
data.Properties.VariableNames(26) = "ap10cd_r";
data.Properties.VariableNames(28) = "ap10cl_r";
data.Properties.VariableNames(30) = "ap10cm_r";
data.Properties.VariableNames(32) = "ap12cd_r";
data.Properties.VariableNames(34) = "ap12cl_r";
data.Properties.VariableNames(36) = "ap12cm_r";
data.Properties.VariableNames(38) = "ap14cd_r";
data.Properties.VariableNames(40) = "ap14cl_r";
data.Properties.VariableNames(42) = "ap14cm_r";
data.Properties.VariableNames(44) = "ap15cd_r";
data.Properties.VariableNames(46) = "ap15cl_r";
data.Properties.VariableNames(48) = "ap15cm_r";
data.Properties.VariableNames(50) = "ap17cd_r";
data.Properties.VariableNames(52) = "ap17cl_r";
data.Properties.VariableNames(54) = "ap17cm_r";
display = find(data.ap10cl_r=="no");
k=display;
k1=string(k);
switch k1
case "yes"
disp(‘convereged’)
case "no"
disp(‘not convereged’)
end
here, i have to change the coulum again and again. i want to automate it in a way that it gives all the values where ‘no’ is at once.
kindly help. excel, loop MATLAB Answers — New Questions