Tag Archives: matlab
Error in Battery.Pulsesequence/Createpulses
Hello everyone,
I am trying to implement the Battery Pulse sequence object for the dataset I have currently.
The example dataset consists of 26 pulses and my dataset has 11.
When I am trying to implement the Pulse sequence object to my dataset, I am ending up with the following error message:
"Index in position 1 exceeds array bounds. Index must not exceed 11.
Error in Battery.PulseSequence/createPulses
Error in Trial_script_test_data (line 30)
psObj.createPulses(‘CurrentOnThreshold’,3) %minimum current magnitude to identify pulse events"
How and where do I define the pulses as 11 in ‘createpulses’
psObj.createPulses(…
‘CurrentOnThreshold’,3,… %minimum current magnitude to identify pulse events
‘NumRCBranches’,2,… %how many RC pairs in the model
‘RCBranchesUse2TimeConstants’,false,… %do RC pairs have different time constant for discharge and rest?
‘PreBufferSamples’,2,… %how many samples to include before the current pulse starts
‘PostBufferSamples’,4); %how many samples to include after the next pulse starts
This is my version of the script.Hello everyone,
I am trying to implement the Battery Pulse sequence object for the dataset I have currently.
The example dataset consists of 26 pulses and my dataset has 11.
When I am trying to implement the Pulse sequence object to my dataset, I am ending up with the following error message:
"Index in position 1 exceeds array bounds. Index must not exceed 11.
Error in Battery.PulseSequence/createPulses
Error in Trial_script_test_data (line 30)
psObj.createPulses(‘CurrentOnThreshold’,3) %minimum current magnitude to identify pulse events"
How and where do I define the pulses as 11 in ‘createpulses’
psObj.createPulses(…
‘CurrentOnThreshold’,3,… %minimum current magnitude to identify pulse events
‘NumRCBranches’,2,… %how many RC pairs in the model
‘RCBranchesUse2TimeConstants’,false,… %do RC pairs have different time constant for discharge and rest?
‘PreBufferSamples’,2,… %how many samples to include before the current pulse starts
‘PostBufferSamples’,4); %how many samples to include after the next pulse starts
This is my version of the script. Hello everyone,
I am trying to implement the Battery Pulse sequence object for the dataset I have currently.
The example dataset consists of 26 pulses and my dataset has 11.
When I am trying to implement the Pulse sequence object to my dataset, I am ending up with the following error message:
"Index in position 1 exceeds array bounds. Index must not exceed 11.
Error in Battery.PulseSequence/createPulses
Error in Trial_script_test_data (line 30)
psObj.createPulses(‘CurrentOnThreshold’,3) %minimum current magnitude to identify pulse events"
How and where do I define the pulses as 11 in ‘createpulses’
psObj.createPulses(…
‘CurrentOnThreshold’,3,… %minimum current magnitude to identify pulse events
‘NumRCBranches’,2,… %how many RC pairs in the model
‘RCBranchesUse2TimeConstants’,false,… %do RC pairs have different time constant for discharge and rest?
‘PreBufferSamples’,2,… %how many samples to include before the current pulse starts
‘PostBufferSamples’,4); %how many samples to include after the next pulse starts
This is my version of the script. battery_system_management, ecm MATLAB Answers — New Questions
using backpropagation neural network for fuel consumption prediction
I want to use three datasets in the model development; the worked hours, the loads and the fuel consumed by the truck.I want to use the worked hours and loads as the inputs(Two Inputs) and the fuel consumed as the target(output data). my dataset is consist of 80 records and i want to divide it into two sub datasets:training and testing. 65% of the total data for training and the remaining 35% for testing so as to validate accuracy of the model.The number of neuron in the hidden layer should be set to 1 initially and the hyperbolic tangent sigmiod function should be used as the transfer function.The data should be run to be run to give an output with the calculated error between the target and the output(predicted). The error should then be back propagated through the network for adjustments.The process should be repeated by varing the neuron number till the error is minimal. The model should then be simulated to ascertain the validity by using the testing data.The optimim number of neuron that gives the best results should be selected based on the correlation coefficient and the mean absolute percentage error for the testing data.The architecture of the BPNN should be developed.Find the data to be used in is below
WORKED HOURS(Hrs) : 299.9 372.3 401.9 429.5 358.3 79.6 310.3 176.4 221.05 187.6 433.6 243 480.5 203.5 426.8 456.6 473.2 350.4 474 161.4 390.8 471.7 266.3 496.6 423.7 320.9 18.1 504.5 531.5 514.8 519.3 513.2 49 206.3 416.8 290.9 368.9 484.6 209 225.6 439.6 461.9 352.3 455.3 475.6 445.1 346.5 469.7 288.7 306.3 170.6 391.7 147.4 392 343.6 223.6 67.1 361.6 279.5 361.3 451.7 76.6 344.8 352.3 347.7 450.6 434.7 365.9 327.6 451.5 433 361.9 180.3 466.5 415.6 461.7 437.1 478.3 325.2 499.7
LOADS (BCM) 1129 972 703 1199 1438 1144 1092 1526 772 1018 1415 1026 424 931 489 1044 135 181 1488 1038 1112 1191 149 1607 830 944 595 744 1126 1386 922 1217 1471 1124 1490 1436 1095 1266 1245 1384 1183 1299 940 1215 1098 1125 929 1307 1253 1407 1471 836 994 1138 1576 1066 1138 1106 1170 1283 942 1420 663 1167 1118 1254 1214 1187 1387 1311 1108 1336 1082 1435 1326 1188 1527 1036 1172 1517
FUEL CONSUMED (l/bcm)
40,733.00 46,375.00 50,797.00 49,706.00 45,092.00 34,543.87 36,687.62 44,899.04 37,023.81 40,458.24 34,383.52 25,914.49 34,300.42 46,685.87 54,122.83 47,242.32 46,296.99 61,800.78 58,181.10 40,579.12 56,890.57 60,295.81 61,843.33 63,156.89 60,320.82 56,141.04 58,063.53 46,379.00 44,011.00 44,191.00 42,089.00 45,682.00 50,666.00 45,643.00 46,568.00 49,162.00 47,871.63 45,012.70 40,345.86 43,233.45 41,408.20 52,169.66 53,161.51 46,553.05 52,353.93 49,019.43 42,015.50 35,327.23 35,025.50 28,207.78 39,435.27 42,200.30 26,677.27 45,977.46 27,870.61 22,335.77 41,153.24 36,260.02 40,901.63 42,274.00 41,501.00 39,189.00 36,349.00 38,545.00 38,625.00 32,907.00 30,153.00 29,142.58 26,813.88 34,488.11 40,575.67 43,439.41 45,374.04 47,730.75 58,335.01 48,531.21 45,510.96 51,891.60 42,902.32 32,819.21I want to use three datasets in the model development; the worked hours, the loads and the fuel consumed by the truck.I want to use the worked hours and loads as the inputs(Two Inputs) and the fuel consumed as the target(output data). my dataset is consist of 80 records and i want to divide it into two sub datasets:training and testing. 65% of the total data for training and the remaining 35% for testing so as to validate accuracy of the model.The number of neuron in the hidden layer should be set to 1 initially and the hyperbolic tangent sigmiod function should be used as the transfer function.The data should be run to be run to give an output with the calculated error between the target and the output(predicted). The error should then be back propagated through the network for adjustments.The process should be repeated by varing the neuron number till the error is minimal. The model should then be simulated to ascertain the validity by using the testing data.The optimim number of neuron that gives the best results should be selected based on the correlation coefficient and the mean absolute percentage error for the testing data.The architecture of the BPNN should be developed.Find the data to be used in is below
WORKED HOURS(Hrs) : 299.9 372.3 401.9 429.5 358.3 79.6 310.3 176.4 221.05 187.6 433.6 243 480.5 203.5 426.8 456.6 473.2 350.4 474 161.4 390.8 471.7 266.3 496.6 423.7 320.9 18.1 504.5 531.5 514.8 519.3 513.2 49 206.3 416.8 290.9 368.9 484.6 209 225.6 439.6 461.9 352.3 455.3 475.6 445.1 346.5 469.7 288.7 306.3 170.6 391.7 147.4 392 343.6 223.6 67.1 361.6 279.5 361.3 451.7 76.6 344.8 352.3 347.7 450.6 434.7 365.9 327.6 451.5 433 361.9 180.3 466.5 415.6 461.7 437.1 478.3 325.2 499.7
LOADS (BCM) 1129 972 703 1199 1438 1144 1092 1526 772 1018 1415 1026 424 931 489 1044 135 181 1488 1038 1112 1191 149 1607 830 944 595 744 1126 1386 922 1217 1471 1124 1490 1436 1095 1266 1245 1384 1183 1299 940 1215 1098 1125 929 1307 1253 1407 1471 836 994 1138 1576 1066 1138 1106 1170 1283 942 1420 663 1167 1118 1254 1214 1187 1387 1311 1108 1336 1082 1435 1326 1188 1527 1036 1172 1517
FUEL CONSUMED (l/bcm)
40,733.00 46,375.00 50,797.00 49,706.00 45,092.00 34,543.87 36,687.62 44,899.04 37,023.81 40,458.24 34,383.52 25,914.49 34,300.42 46,685.87 54,122.83 47,242.32 46,296.99 61,800.78 58,181.10 40,579.12 56,890.57 60,295.81 61,843.33 63,156.89 60,320.82 56,141.04 58,063.53 46,379.00 44,011.00 44,191.00 42,089.00 45,682.00 50,666.00 45,643.00 46,568.00 49,162.00 47,871.63 45,012.70 40,345.86 43,233.45 41,408.20 52,169.66 53,161.51 46,553.05 52,353.93 49,019.43 42,015.50 35,327.23 35,025.50 28,207.78 39,435.27 42,200.30 26,677.27 45,977.46 27,870.61 22,335.77 41,153.24 36,260.02 40,901.63 42,274.00 41,501.00 39,189.00 36,349.00 38,545.00 38,625.00 32,907.00 30,153.00 29,142.58 26,813.88 34,488.11 40,575.67 43,439.41 45,374.04 47,730.75 58,335.01 48,531.21 45,510.96 51,891.60 42,902.32 32,819.21 I want to use three datasets in the model development; the worked hours, the loads and the fuel consumed by the truck.I want to use the worked hours and loads as the inputs(Two Inputs) and the fuel consumed as the target(output data). my dataset is consist of 80 records and i want to divide it into two sub datasets:training and testing. 65% of the total data for training and the remaining 35% for testing so as to validate accuracy of the model.The number of neuron in the hidden layer should be set to 1 initially and the hyperbolic tangent sigmiod function should be used as the transfer function.The data should be run to be run to give an output with the calculated error between the target and the output(predicted). The error should then be back propagated through the network for adjustments.The process should be repeated by varing the neuron number till the error is minimal. The model should then be simulated to ascertain the validity by using the testing data.The optimim number of neuron that gives the best results should be selected based on the correlation coefficient and the mean absolute percentage error for the testing data.The architecture of the BPNN should be developed.Find the data to be used in is below
WORKED HOURS(Hrs) : 299.9 372.3 401.9 429.5 358.3 79.6 310.3 176.4 221.05 187.6 433.6 243 480.5 203.5 426.8 456.6 473.2 350.4 474 161.4 390.8 471.7 266.3 496.6 423.7 320.9 18.1 504.5 531.5 514.8 519.3 513.2 49 206.3 416.8 290.9 368.9 484.6 209 225.6 439.6 461.9 352.3 455.3 475.6 445.1 346.5 469.7 288.7 306.3 170.6 391.7 147.4 392 343.6 223.6 67.1 361.6 279.5 361.3 451.7 76.6 344.8 352.3 347.7 450.6 434.7 365.9 327.6 451.5 433 361.9 180.3 466.5 415.6 461.7 437.1 478.3 325.2 499.7
LOADS (BCM) 1129 972 703 1199 1438 1144 1092 1526 772 1018 1415 1026 424 931 489 1044 135 181 1488 1038 1112 1191 149 1607 830 944 595 744 1126 1386 922 1217 1471 1124 1490 1436 1095 1266 1245 1384 1183 1299 940 1215 1098 1125 929 1307 1253 1407 1471 836 994 1138 1576 1066 1138 1106 1170 1283 942 1420 663 1167 1118 1254 1214 1187 1387 1311 1108 1336 1082 1435 1326 1188 1527 1036 1172 1517
FUEL CONSUMED (l/bcm)
40,733.00 46,375.00 50,797.00 49,706.00 45,092.00 34,543.87 36,687.62 44,899.04 37,023.81 40,458.24 34,383.52 25,914.49 34,300.42 46,685.87 54,122.83 47,242.32 46,296.99 61,800.78 58,181.10 40,579.12 56,890.57 60,295.81 61,843.33 63,156.89 60,320.82 56,141.04 58,063.53 46,379.00 44,011.00 44,191.00 42,089.00 45,682.00 50,666.00 45,643.00 46,568.00 49,162.00 47,871.63 45,012.70 40,345.86 43,233.45 41,408.20 52,169.66 53,161.51 46,553.05 52,353.93 49,019.43 42,015.50 35,327.23 35,025.50 28,207.78 39,435.27 42,200.30 26,677.27 45,977.46 27,870.61 22,335.77 41,153.24 36,260.02 40,901.63 42,274.00 41,501.00 39,189.00 36,349.00 38,545.00 38,625.00 32,907.00 30,153.00 29,142.58 26,813.88 34,488.11 40,575.67 43,439.41 45,374.04 47,730.75 58,335.01 48,531.21 45,510.96 51,891.60 42,902.32 32,819.21 modeling, machine learning, neural network, fuel vs loads time MATLAB Answers — New Questions
Global ylabel and colorbar in tiledlayout environment
Dear all
I am creating a figure in tiledlayout environment through a code of the form:
% First layer
u1=figure(‘visible’,’off’,’units’,’pixels’,’position’,[0 0 1920 1080]);
t=tiledlayout("vertical");
title(t,[‘Trilayer. First layer. LLG-Heun, $t=1.09$ ns. $T=0$ K, $mathbf{H}=left( 0.5 , , mathrm{T} right) mathbf{hat{z}}$’;”;”],’FontSize’,19,’interpreter’,’latex’);
nexttile;
uimagesc(space_x,space_y,lx_1);
axis xy;
clim([-1 1]);
colormap(bluewhitered(256));
box on;
xlim([0 200]);
xticks([0:50:200]);
ylim([0 50]);
yticks([0:10:50]);
pbaspect([max(space_x)/max(space_y) 1 1]);
xtickangle(0);
set(gca,’TickLabelInterpreter’,’latex’,’FontSize’,18);
t1=title([‘$l^{mathrm{intra}}_x$’],’FontSize’,20,’interpreter’,’latex’);
set(t1,’interpreter’,’latex’,’FontSize’,20);
set(gca,’XTickLabel’,[]);
yticks([0:50/4:50]);
nexttile;
uimagesc(space_x,space_y,ly_1);
clim([-1 1]);
colormap(bluewhitered(256));
axis xy;
box on;
clr2=colorbar;
set(clr2,’TickLabelInterpreter’,’latex’);
ylabel(‘$y$-{it th} spatial direction, $y , , left( mathrm{nm} right)$’,’FontSize’,18,’interpreter’,’latex’);
ylabel(clr2,’$i$-{it th} intralayer Ne”el vector component, $l^{mathrm{intra}}_i$’,’Interpreter’,’Latex’,’FontSize’,19);
xlim([0 200]);
xticks([0:50:200]);
ylim([0 50]);
yticks([0:10:50]);
pbaspect([max(space_x)/max(space_y) 1 1]);
xtickangle(0);
set(gca,’TickLabelInterpreter’,’latex’,’FontSize’,18);
t2=title([‘$l^{mathrm{intra}}_y$’],’FontSize’,20,’interpreter’,’latex’);
set(t2,’interpreter’,’latex’,’FontSize’,20);
set(gca,’XTickLabel’,[]);
yticks([0:50/4:50]);
nexttile;
uimagesc(space_x,space_y,lz_1);
box on;
axis xy;
clim([-1 1]);
colormap(bluewhitered(256));
xlabel(‘$x$-{it th} spatial direction, $x , , left( mathrm{nm} right)$’,’FontSize’,18,’interpreter’,’latex’);
xlim([0 200]);
xticks([0:50:200]);
ylim([0 50]);
yticks([0:10:50]);
pbaspect([max(space_x)/max(space_y) 1 1]);
xtickangle(0);
set(gca,’TickLabelInterpreter’,’latex’,’FontSize’,18);
t3=title([‘$l^{mathrm{intra}}_z$’],’FontSize’,20,’interpreter’,’latex’);
set(t3,’interpreter’,’latex’,’FontSize’,20);
yticks([0:50/4:50]);
set(gcf,’color’,’white’);
set(gca,’Units’,’normalized’);
set(u1,’Units’,’Inches’);
posu1=get(u1,’Position’);
set(u1,’PaperPositionMode’,’Auto’,’PaperUnits’,’Inches’,’PaperSize’,[posu1(3),posu1(4)]);
which gives rise to:
I would like to have the ylabel "y-th spatial direction…" centered in the second plot, but covering the three y-axis (as it is now, but with a higher separation from the yticklabels (0 12.5…) to the left. Moreover, I want the same for the colorbar, that it is, to be the global one for the three plots, with higher horizontal separation to the right, and with a longer aspect (from the bottom of the bottom plot to the top of the top plot).
Any ideas?Dear all
I am creating a figure in tiledlayout environment through a code of the form:
% First layer
u1=figure(‘visible’,’off’,’units’,’pixels’,’position’,[0 0 1920 1080]);
t=tiledlayout("vertical");
title(t,[‘Trilayer. First layer. LLG-Heun, $t=1.09$ ns. $T=0$ K, $mathbf{H}=left( 0.5 , , mathrm{T} right) mathbf{hat{z}}$’;”;”],’FontSize’,19,’interpreter’,’latex’);
nexttile;
uimagesc(space_x,space_y,lx_1);
axis xy;
clim([-1 1]);
colormap(bluewhitered(256));
box on;
xlim([0 200]);
xticks([0:50:200]);
ylim([0 50]);
yticks([0:10:50]);
pbaspect([max(space_x)/max(space_y) 1 1]);
xtickangle(0);
set(gca,’TickLabelInterpreter’,’latex’,’FontSize’,18);
t1=title([‘$l^{mathrm{intra}}_x$’],’FontSize’,20,’interpreter’,’latex’);
set(t1,’interpreter’,’latex’,’FontSize’,20);
set(gca,’XTickLabel’,[]);
yticks([0:50/4:50]);
nexttile;
uimagesc(space_x,space_y,ly_1);
clim([-1 1]);
colormap(bluewhitered(256));
axis xy;
box on;
clr2=colorbar;
set(clr2,’TickLabelInterpreter’,’latex’);
ylabel(‘$y$-{it th} spatial direction, $y , , left( mathrm{nm} right)$’,’FontSize’,18,’interpreter’,’latex’);
ylabel(clr2,’$i$-{it th} intralayer Ne”el vector component, $l^{mathrm{intra}}_i$’,’Interpreter’,’Latex’,’FontSize’,19);
xlim([0 200]);
xticks([0:50:200]);
ylim([0 50]);
yticks([0:10:50]);
pbaspect([max(space_x)/max(space_y) 1 1]);
xtickangle(0);
set(gca,’TickLabelInterpreter’,’latex’,’FontSize’,18);
t2=title([‘$l^{mathrm{intra}}_y$’],’FontSize’,20,’interpreter’,’latex’);
set(t2,’interpreter’,’latex’,’FontSize’,20);
set(gca,’XTickLabel’,[]);
yticks([0:50/4:50]);
nexttile;
uimagesc(space_x,space_y,lz_1);
box on;
axis xy;
clim([-1 1]);
colormap(bluewhitered(256));
xlabel(‘$x$-{it th} spatial direction, $x , , left( mathrm{nm} right)$’,’FontSize’,18,’interpreter’,’latex’);
xlim([0 200]);
xticks([0:50:200]);
ylim([0 50]);
yticks([0:10:50]);
pbaspect([max(space_x)/max(space_y) 1 1]);
xtickangle(0);
set(gca,’TickLabelInterpreter’,’latex’,’FontSize’,18);
t3=title([‘$l^{mathrm{intra}}_z$’],’FontSize’,20,’interpreter’,’latex’);
set(t3,’interpreter’,’latex’,’FontSize’,20);
yticks([0:50/4:50]);
set(gcf,’color’,’white’);
set(gca,’Units’,’normalized’);
set(u1,’Units’,’Inches’);
posu1=get(u1,’Position’);
set(u1,’PaperPositionMode’,’Auto’,’PaperUnits’,’Inches’,’PaperSize’,[posu1(3),posu1(4)]);
which gives rise to:
I would like to have the ylabel "y-th spatial direction…" centered in the second plot, but covering the three y-axis (as it is now, but with a higher separation from the yticklabels (0 12.5…) to the left. Moreover, I want the same for the colorbar, that it is, to be the global one for the three plots, with higher horizontal separation to the right, and with a longer aspect (from the bottom of the bottom plot to the top of the top plot).
Any ideas? Dear all
I am creating a figure in tiledlayout environment through a code of the form:
% First layer
u1=figure(‘visible’,’off’,’units’,’pixels’,’position’,[0 0 1920 1080]);
t=tiledlayout("vertical");
title(t,[‘Trilayer. First layer. LLG-Heun, $t=1.09$ ns. $T=0$ K, $mathbf{H}=left( 0.5 , , mathrm{T} right) mathbf{hat{z}}$’;”;”],’FontSize’,19,’interpreter’,’latex’);
nexttile;
uimagesc(space_x,space_y,lx_1);
axis xy;
clim([-1 1]);
colormap(bluewhitered(256));
box on;
xlim([0 200]);
xticks([0:50:200]);
ylim([0 50]);
yticks([0:10:50]);
pbaspect([max(space_x)/max(space_y) 1 1]);
xtickangle(0);
set(gca,’TickLabelInterpreter’,’latex’,’FontSize’,18);
t1=title([‘$l^{mathrm{intra}}_x$’],’FontSize’,20,’interpreter’,’latex’);
set(t1,’interpreter’,’latex’,’FontSize’,20);
set(gca,’XTickLabel’,[]);
yticks([0:50/4:50]);
nexttile;
uimagesc(space_x,space_y,ly_1);
clim([-1 1]);
colormap(bluewhitered(256));
axis xy;
box on;
clr2=colorbar;
set(clr2,’TickLabelInterpreter’,’latex’);
ylabel(‘$y$-{it th} spatial direction, $y , , left( mathrm{nm} right)$’,’FontSize’,18,’interpreter’,’latex’);
ylabel(clr2,’$i$-{it th} intralayer Ne”el vector component, $l^{mathrm{intra}}_i$’,’Interpreter’,’Latex’,’FontSize’,19);
xlim([0 200]);
xticks([0:50:200]);
ylim([0 50]);
yticks([0:10:50]);
pbaspect([max(space_x)/max(space_y) 1 1]);
xtickangle(0);
set(gca,’TickLabelInterpreter’,’latex’,’FontSize’,18);
t2=title([‘$l^{mathrm{intra}}_y$’],’FontSize’,20,’interpreter’,’latex’);
set(t2,’interpreter’,’latex’,’FontSize’,20);
set(gca,’XTickLabel’,[]);
yticks([0:50/4:50]);
nexttile;
uimagesc(space_x,space_y,lz_1);
box on;
axis xy;
clim([-1 1]);
colormap(bluewhitered(256));
xlabel(‘$x$-{it th} spatial direction, $x , , left( mathrm{nm} right)$’,’FontSize’,18,’interpreter’,’latex’);
xlim([0 200]);
xticks([0:50:200]);
ylim([0 50]);
yticks([0:10:50]);
pbaspect([max(space_x)/max(space_y) 1 1]);
xtickangle(0);
set(gca,’TickLabelInterpreter’,’latex’,’FontSize’,18);
t3=title([‘$l^{mathrm{intra}}_z$’],’FontSize’,20,’interpreter’,’latex’);
set(t3,’interpreter’,’latex’,’FontSize’,20);
yticks([0:50/4:50]);
set(gcf,’color’,’white’);
set(gca,’Units’,’normalized’);
set(u1,’Units’,’Inches’);
posu1=get(u1,’Position’);
set(u1,’PaperPositionMode’,’Auto’,’PaperUnits’,’Inches’,’PaperSize’,[posu1(3),posu1(4)]);
which gives rise to:
I would like to have the ylabel "y-th spatial direction…" centered in the second plot, but covering the three y-axis (as it is now, but with a higher separation from the yticklabels (0 12.5…) to the left. Moreover, I want the same for the colorbar, that it is, to be the global one for the three plots, with higher horizontal separation to the right, and with a longer aspect (from the bottom of the bottom plot to the top of the top plot).
Any ideas? tiledlayout MATLAB Answers — New Questions
Graphic display problem after using normalized coordinates in Matlab
Hi,guys.
I encountered a problem. That is, when I use normalized coordinates, no matter how I adjust the diameter of my target circle, there is no change in the image. I can feel the change in the coordinates. But I don’t need this. I want the entire image to change after adjusting the diameter.
Here are the codes:
function startTask()
targetCenters = zeros(8, 2);
angles = linspace(0, 2*pi, 9);
angles = angles(1:end-1);
radii = 0.3;
waitingForNextTarget = false;
firstMove = true;
resetPosition = [0, 0];
targetSequence = [1,3,5,7,2,4,6,8,8,6,4,2,7,5,3,1];
currentSequenceIndex = 1;
for i = 1:length(angles)
targetCenters(i, 1) = radii * cos(angles(i));
targetCenters(i, 2) = radii * sin(angles(i));
end
targetActivated = false;
currentTarget = 0;
hoverStartTime = [];
cyclesCompleted = 0;
maxCycles = 64;
mousePath = [];
mouseDot = [];
x = 0;
y = 0;
timerObj = timer(‘TimerFcn’, @recordMousePos, ‘Period’, 0.02 , ‘ExecutionMode’, ‘fixedRate’);
checkTargetTimer = timer(‘TimerFcn’, @checkAndActivateTarget, ‘Period’, 0.02 , ‘ExecutionMode’, ‘fixedRate’);
start(checkTargetTimer);
fig = figure(‘Color’, ‘black’, ‘Pointer’, ‘custom’, ‘Units’, ‘normalized’, ‘Position’, [0 0 1 1], ‘MenuBar’, ‘none’, ‘ToolBar’, ‘none’);
ax = axes(‘Color’, ‘black’, ‘Units’, ‘normalized’, ‘Position’, [0 0 1 1], ‘DataAspectRatio’, [1 1 1]);
axis off;
hold on;
drawCircles();
set(fig, ‘WindowButtonMotionFcn’, @mouseMoved);
setInvisibleCursor();
showBlackPanelScreen(2)
resetMouseAndDotPositionToCenter();
activateRandomTarget();
function setInvisibleCursor()
transparentCursor = NaN(16, 16);
hotspot = [8, 8];
set(fig, ‘Pointer’, ‘custom’, ‘PointerShapeCData’, transparentCursor, ‘PointerShapeHotSpot’, hotspot);
end
function drawCircles()
angles = linspace(0, 2*pi, 9);
angles = angles(1:end-1);
circleDiameter = radii * 0.2;
%axis equal;
for i = 1:length(angles)
x = radii * cos(angles(i));
y = radii * sin(angles(i));
rectangle(‘Position’, [x – circleDiameter/2, y – circleDiameter/2, circleDiameter, circleDiameter], ‘Curvature’, [1, 1], ‘EdgeColor’, ‘w’, ‘FaceColor’, ‘k’, ‘LineStyle’, ‘–‘, ‘LineWidth’, 3, ‘UserData’, i);
end
end
SichengHi,guys.
I encountered a problem. That is, when I use normalized coordinates, no matter how I adjust the diameter of my target circle, there is no change in the image. I can feel the change in the coordinates. But I don’t need this. I want the entire image to change after adjusting the diameter.
Here are the codes:
function startTask()
targetCenters = zeros(8, 2);
angles = linspace(0, 2*pi, 9);
angles = angles(1:end-1);
radii = 0.3;
waitingForNextTarget = false;
firstMove = true;
resetPosition = [0, 0];
targetSequence = [1,3,5,7,2,4,6,8,8,6,4,2,7,5,3,1];
currentSequenceIndex = 1;
for i = 1:length(angles)
targetCenters(i, 1) = radii * cos(angles(i));
targetCenters(i, 2) = radii * sin(angles(i));
end
targetActivated = false;
currentTarget = 0;
hoverStartTime = [];
cyclesCompleted = 0;
maxCycles = 64;
mousePath = [];
mouseDot = [];
x = 0;
y = 0;
timerObj = timer(‘TimerFcn’, @recordMousePos, ‘Period’, 0.02 , ‘ExecutionMode’, ‘fixedRate’);
checkTargetTimer = timer(‘TimerFcn’, @checkAndActivateTarget, ‘Period’, 0.02 , ‘ExecutionMode’, ‘fixedRate’);
start(checkTargetTimer);
fig = figure(‘Color’, ‘black’, ‘Pointer’, ‘custom’, ‘Units’, ‘normalized’, ‘Position’, [0 0 1 1], ‘MenuBar’, ‘none’, ‘ToolBar’, ‘none’);
ax = axes(‘Color’, ‘black’, ‘Units’, ‘normalized’, ‘Position’, [0 0 1 1], ‘DataAspectRatio’, [1 1 1]);
axis off;
hold on;
drawCircles();
set(fig, ‘WindowButtonMotionFcn’, @mouseMoved);
setInvisibleCursor();
showBlackPanelScreen(2)
resetMouseAndDotPositionToCenter();
activateRandomTarget();
function setInvisibleCursor()
transparentCursor = NaN(16, 16);
hotspot = [8, 8];
set(fig, ‘Pointer’, ‘custom’, ‘PointerShapeCData’, transparentCursor, ‘PointerShapeHotSpot’, hotspot);
end
function drawCircles()
angles = linspace(0, 2*pi, 9);
angles = angles(1:end-1);
circleDiameter = radii * 0.2;
%axis equal;
for i = 1:length(angles)
x = radii * cos(angles(i));
y = radii * sin(angles(i));
rectangle(‘Position’, [x – circleDiameter/2, y – circleDiameter/2, circleDiameter, circleDiameter], ‘Curvature’, [1, 1], ‘EdgeColor’, ‘w’, ‘FaceColor’, ‘k’, ‘LineStyle’, ‘–‘, ‘LineWidth’, 3, ‘UserData’, i);
end
end
Sicheng Hi,guys.
I encountered a problem. That is, when I use normalized coordinates, no matter how I adjust the diameter of my target circle, there is no change in the image. I can feel the change in the coordinates. But I don’t need this. I want the entire image to change after adjusting the diameter.
Here are the codes:
function startTask()
targetCenters = zeros(8, 2);
angles = linspace(0, 2*pi, 9);
angles = angles(1:end-1);
radii = 0.3;
waitingForNextTarget = false;
firstMove = true;
resetPosition = [0, 0];
targetSequence = [1,3,5,7,2,4,6,8,8,6,4,2,7,5,3,1];
currentSequenceIndex = 1;
for i = 1:length(angles)
targetCenters(i, 1) = radii * cos(angles(i));
targetCenters(i, 2) = radii * sin(angles(i));
end
targetActivated = false;
currentTarget = 0;
hoverStartTime = [];
cyclesCompleted = 0;
maxCycles = 64;
mousePath = [];
mouseDot = [];
x = 0;
y = 0;
timerObj = timer(‘TimerFcn’, @recordMousePos, ‘Period’, 0.02 , ‘ExecutionMode’, ‘fixedRate’);
checkTargetTimer = timer(‘TimerFcn’, @checkAndActivateTarget, ‘Period’, 0.02 , ‘ExecutionMode’, ‘fixedRate’);
start(checkTargetTimer);
fig = figure(‘Color’, ‘black’, ‘Pointer’, ‘custom’, ‘Units’, ‘normalized’, ‘Position’, [0 0 1 1], ‘MenuBar’, ‘none’, ‘ToolBar’, ‘none’);
ax = axes(‘Color’, ‘black’, ‘Units’, ‘normalized’, ‘Position’, [0 0 1 1], ‘DataAspectRatio’, [1 1 1]);
axis off;
hold on;
drawCircles();
set(fig, ‘WindowButtonMotionFcn’, @mouseMoved);
setInvisibleCursor();
showBlackPanelScreen(2)
resetMouseAndDotPositionToCenter();
activateRandomTarget();
function setInvisibleCursor()
transparentCursor = NaN(16, 16);
hotspot = [8, 8];
set(fig, ‘Pointer’, ‘custom’, ‘PointerShapeCData’, transparentCursor, ‘PointerShapeHotSpot’, hotspot);
end
function drawCircles()
angles = linspace(0, 2*pi, 9);
angles = angles(1:end-1);
circleDiameter = radii * 0.2;
%axis equal;
for i = 1:length(angles)
x = radii * cos(angles(i));
y = radii * sin(angles(i));
rectangle(‘Position’, [x – circleDiameter/2, y – circleDiameter/2, circleDiameter, circleDiameter], ‘Curvature’, [1, 1], ‘EdgeColor’, ‘w’, ‘FaceColor’, ‘k’, ‘LineStyle’, ‘–‘, ‘LineWidth’, 3, ‘UserData’, i);
end
end
Sicheng graphics,, normalized coordinates MATLAB Answers — New Questions
obtaining single polynomial equation using Heun’s method from 4 second order differential equations
I get this error when trying to solve these 4 second order differential equations using a program that solves them using Heun’s method and then Gaussian elimination to get a polynomial equation the represents the system. Previsouly posted for help, but the soluitions have symbolics and I need a singular soluition that represents all 4 equations. Does any one have a suggestion on how I can slove this? Is using the "function" with all 4 equations the best way to do this, or is there a nicer method for doing this?
clear,close,clc
%______________________________________________________________SOLUITION_2_Heun’s_Method_(for second order differential equations)_&__Least-Square_Nethod____________________________________________________________%
%4 Equations representing the system working with
% MfXf"=Ksf([Xb-(L1*theta)]-Xf)+Bsf([Xb’-(L1*theta’)-Xf’)-(Kf*Xf);
% MrXr"=Ksr([Xb+(L2*theta)]-Xr)+Bsr([Xb’+(L2*theta’)]-Xr’)-(Kr*Xr) ;
% MbXb"=Ksf([Xb-(L1*theta)]-Xf)+Bsf([Xb’-(L1*theta’)]-Xf’)+Ksr([Xb+(L2*theta)]-Xr)+Bsr([Xb’+(L2*theta’)]-Xr’)+fa(t);
% Ic*theta"={-[Ksf(Xf-(L1*theta))*L1]-[Bsf(Xf’-(L1*theta’))*L1]+[Ksr(Xr+(L2*theta))*L2]+[Bsr(Xr’+(L2*theta’))*L2]+[fa(t)*L3]};
%————————————————-SYSTEM_PARAMETERS———————————————————————————————————————————————————-
Ic=1356; %kg-m^2
Mb=730; %kg
Mf=59; %kg
Mr=45; %kg
Kf=23000; %N/m
Ksf=18750; %N/m
Kr=16182; %N/m
Ksr=12574; %N/m
Bsf=100; %N*s/m
Bsr=100; %N*s/m
L1=1.45; %m
L2=1.39; %m
L3=0.67; %m
t0=0; %time at the start
tm=20; %what value of (t time) you are ending at
t=t0:tm; % time from time start to time finish seconds
n=4; %order of the polynomial
%Initial Conditions-system at rest therefore x(0)=0 dXf/dt(0)=0 dXr/dt(0)=0 dXb/dt(0)=0 dtheta/dt(0)=0 ;
%time from 0 to 20 h=dx=5;
x0=0; %x at initial condition
y0=0; %y at initial condition
dx=5; %delta(x) or h
h=dx;
%==INPUT SECTION for Euler’s and Heun’s==%
fx=@(x,y,t)y;
fy=@(x,y,t)Projectfunction;
%==CALCULATIONS SECTION==%
tn=t0:h:tm;
xn(1) = x0;
yn(1) = y0;
for i=1:length(tn)
%==EULER’S METHOD
xn(i+1)=xn(i)+fx(xn(i),yn(i),tn(i))*h;
yn(i+1)=yn(i)+fy(xn(i),yn(i),tn(i))*h;
%==NEXT 3 LINES ARE FOR HEUN’S METHOD
tn(i+1)=tn(i)+h;
xn(i+1)=xn(i)+0.5*(fx(xn(i),yn(i),tn(i))+fx(xn(i+1),yn(i+1),tn(i+1)))*h;
yn(i+1)=yn(i)+0.5*(fy(xn(i),yn(i),tn(i))+fy(xn(i+1),yn(i+1),tn(i+1)))*h;
fprintf(‘t=%0.2ft y=%0.3ft z=%0.3fn’,tn(i),xn(i),yn(i))
end
%%%LEAST SQUARE METHOD-FINDS POLYNOMIAL FOR GIVEN DATA SET%%%%%
%INPUT SECTION for Least-Square
X=xn;
Y=yn;
%%__CALCULATIONS SECTION__%%
k=length(X); %NUMBER OF AVAILABLE DATA POINTS
m=n+1; %SIZE OF THE COEFFICENT MATRIX
A=zeros(m,m); %COEFFICENT MATRIX
for j=1:m
for i=1:m
A(j,i)=sum(X.^(i+j-2));
end
end
B=zeros(m,1); %FORCING FUNCTION VECTOR
for i=1:m;
B(i)=sum(Y.*X.^(i-1));
end
a1=AB %COEFFICIENTS FOR THE POLYNOMINAL–> y=a0+a1*x+a2*x^2….an*x^n CAN BE REPLACED BY GAUSSIAN ELIMINATION
%%%%%=========GAUSSIAN ELIMINATION TO FIND "a"========%%%%%%
%%%INPUT SECTION
%CALCULATION SECTION
AB=[A B]; %Augumentent matrix
R=size(AB,1); %# OF ROWS IN AB
C=size(AB,2); %# OF COLUMNS IN AB
%%%%FOWARD ELIMINATION SECTION
for J=1:R-1
[M,I]=max(abs(AB(J:R,J))); %M=MAXIMUM VALUE, I=LOCATION OF THE MAXIMUM VALUE IN THE 1ST ROW
temp=AB(J,:);
AB(J,:)=AB(I+(J-1),:);
AB(I+(J-1),:)=temp;
for i=(J+1):R;
if AB(i,J)~=0;
AB(i,:)=AB(i,:)-(AB(i,J)/AB(J,J))*AB(J,:);
end
end
end
%%%%BACKWARDS SUBSTITUTION
a(R)=AB(R,C)/AB(R,R);
for i=R-1:-1:1
a(i)=(AB(i,C)-AB(i,i+1:R)*a(i+1:R)’)/AB(i,i);
end
disp(a)
syms X
P=0;
for i=1:m;
TT=a(i)*X^(i-1); %T=INDIVIDUAL POLYNOMIAL TERMS
P=P+TT;
end
display(P)
%========END OF GAUSSIAN ELIMINATION=======%%%%%%%%
%STANDARD DEVIATION
Y_bar=mean(Y); %ADVERAGE OF y
St=sum((Y-Y_bar).^2);
SD=sqrt(St/(k-1)); %STANDARD DEVIATION
%STANDARD ERROR
for i=1:m;
T(:,i)=a(i)*X.^(i-1); %T=INDIVIDUAL POLYNOMIAL TERMS
end
for i=1:k
y_hat(i)=sum(T(i,:));
end
Sr=sum((Y-y_hat).^2);
Se=sqrt(Sr/(k-(n+1))); %STANDARD ERROR-Se
%COEFFICIENT OF DETERMINATION
Cd=(St-Sr)/St %COEFFICIENT OF DETERMINATION (r^2)
Cd = 1.0000
fprintf(‘For n=%d. Coefficient of Determination=%0.5fn’,n,Cd)
function [dydt] = Projectfunction(t,x,y)
Ic=1356; %kg-m^2
Mb=730; %kg
Mf=59; %kg
Mr=45; %kg
Kf=23000; %N/m
Ksf=18750; %N/m
Kr=16182; %N/m
Ksr=12574; %N/m
Bsf=100; %N*s/m
Bsr=100; %N*s/m
L1=1.45; %m
L2=1.39; %m
L3=0.67; %m
x1 = x(1); %x1=Xf
x2 = x(2); %x2=Xr
x3 = x(3); %x3=Xb
x4 = x(4); %x4=theta
y1 = y(1); %y1=Xf’=dXf/dt
y2 = y(2); %y2=Xr’=dXr/dt
y3 = y(3); %y3=Xb’=dXb/dt
y4 = y(4); %y4=theta’=dtheta/dt
dydt1 = (Ksf*((x3-(L1*x4)))-x1)+Bsf*((y3-(L1*y4)-y1)-(Kf*x1))/Mf;
dydt2 = (Ksr*((x3+(L2*x4))-x2)+Bsr*((y3+(L2*y4))-y2)-(Kr*x2))/Mr;
dydt3 = (Ksf*((x3-(L1*x4))-x1)+Bsf*((y3-(L1*y4))-y1)+Ksr*((x3+(L2*x4))-x2)+Bsr*((y3+(L2*y4))-y2)-(10*exp(-(5*t))))/Mb;
dydt4 = ((-(Ksf*(x1-(L1*x4))*L1)-(Bsf*(y1-(L1*y4))*L1)+(Ksr*(x2+(L2*x4))*L2)+(Bsr*(y2+(L2*y4))*L2)+((10*exp(-(5*t)))*L3)))/Ic;
[dydt] = [dydt1; dydt2; dydt3; dydt4];
end
% MfXf"=Ksf([Xb-(L1*theta)]-Xf)+Bsf([Xb’-(L1*theta’)-Xf’)-(Kf*Xf);
% MrXr"=Ksr([Xb+(L2*theta)]-Xr)+Bsr([Xb’+(L2*theta’)]-Xr’)-(Kr*Xr) ;
% MbXb"=Ksf([Xb-(L1*theta)]-Xf)+Bsf([Xb’-(L1*theta’)]-Xf’)+Ksr([Xb+(L2*theta)]-Xr)+Bsr([Xb’+(L2*theta’)]-Xr’)+fa(t);
% Ic*theta"={-[Ksf(Xf-(L1*theta))*L1]-[Bsf(Xf’-(L1*theta’))*L1]+[Ksr(Xr+(L2*theta))*L2]+[Bsr(Xr’+(L2*theta’))*L2]+[fa(t)*L3]};I get this error when trying to solve these 4 second order differential equations using a program that solves them using Heun’s method and then Gaussian elimination to get a polynomial equation the represents the system. Previsouly posted for help, but the soluitions have symbolics and I need a singular soluition that represents all 4 equations. Does any one have a suggestion on how I can slove this? Is using the "function" with all 4 equations the best way to do this, or is there a nicer method for doing this?
clear,close,clc
%______________________________________________________________SOLUITION_2_Heun’s_Method_(for second order differential equations)_&__Least-Square_Nethod____________________________________________________________%
%4 Equations representing the system working with
% MfXf"=Ksf([Xb-(L1*theta)]-Xf)+Bsf([Xb’-(L1*theta’)-Xf’)-(Kf*Xf);
% MrXr"=Ksr([Xb+(L2*theta)]-Xr)+Bsr([Xb’+(L2*theta’)]-Xr’)-(Kr*Xr) ;
% MbXb"=Ksf([Xb-(L1*theta)]-Xf)+Bsf([Xb’-(L1*theta’)]-Xf’)+Ksr([Xb+(L2*theta)]-Xr)+Bsr([Xb’+(L2*theta’)]-Xr’)+fa(t);
% Ic*theta"={-[Ksf(Xf-(L1*theta))*L1]-[Bsf(Xf’-(L1*theta’))*L1]+[Ksr(Xr+(L2*theta))*L2]+[Bsr(Xr’+(L2*theta’))*L2]+[fa(t)*L3]};
%————————————————-SYSTEM_PARAMETERS———————————————————————————————————————————————————-
Ic=1356; %kg-m^2
Mb=730; %kg
Mf=59; %kg
Mr=45; %kg
Kf=23000; %N/m
Ksf=18750; %N/m
Kr=16182; %N/m
Ksr=12574; %N/m
Bsf=100; %N*s/m
Bsr=100; %N*s/m
L1=1.45; %m
L2=1.39; %m
L3=0.67; %m
t0=0; %time at the start
tm=20; %what value of (t time) you are ending at
t=t0:tm; % time from time start to time finish seconds
n=4; %order of the polynomial
%Initial Conditions-system at rest therefore x(0)=0 dXf/dt(0)=0 dXr/dt(0)=0 dXb/dt(0)=0 dtheta/dt(0)=0 ;
%time from 0 to 20 h=dx=5;
x0=0; %x at initial condition
y0=0; %y at initial condition
dx=5; %delta(x) or h
h=dx;
%==INPUT SECTION for Euler’s and Heun’s==%
fx=@(x,y,t)y;
fy=@(x,y,t)Projectfunction;
%==CALCULATIONS SECTION==%
tn=t0:h:tm;
xn(1) = x0;
yn(1) = y0;
for i=1:length(tn)
%==EULER’S METHOD
xn(i+1)=xn(i)+fx(xn(i),yn(i),tn(i))*h;
yn(i+1)=yn(i)+fy(xn(i),yn(i),tn(i))*h;
%==NEXT 3 LINES ARE FOR HEUN’S METHOD
tn(i+1)=tn(i)+h;
xn(i+1)=xn(i)+0.5*(fx(xn(i),yn(i),tn(i))+fx(xn(i+1),yn(i+1),tn(i+1)))*h;
yn(i+1)=yn(i)+0.5*(fy(xn(i),yn(i),tn(i))+fy(xn(i+1),yn(i+1),tn(i+1)))*h;
fprintf(‘t=%0.2ft y=%0.3ft z=%0.3fn’,tn(i),xn(i),yn(i))
end
%%%LEAST SQUARE METHOD-FINDS POLYNOMIAL FOR GIVEN DATA SET%%%%%
%INPUT SECTION for Least-Square
X=xn;
Y=yn;
%%__CALCULATIONS SECTION__%%
k=length(X); %NUMBER OF AVAILABLE DATA POINTS
m=n+1; %SIZE OF THE COEFFICENT MATRIX
A=zeros(m,m); %COEFFICENT MATRIX
for j=1:m
for i=1:m
A(j,i)=sum(X.^(i+j-2));
end
end
B=zeros(m,1); %FORCING FUNCTION VECTOR
for i=1:m;
B(i)=sum(Y.*X.^(i-1));
end
a1=AB %COEFFICIENTS FOR THE POLYNOMINAL–> y=a0+a1*x+a2*x^2….an*x^n CAN BE REPLACED BY GAUSSIAN ELIMINATION
%%%%%=========GAUSSIAN ELIMINATION TO FIND "a"========%%%%%%
%%%INPUT SECTION
%CALCULATION SECTION
AB=[A B]; %Augumentent matrix
R=size(AB,1); %# OF ROWS IN AB
C=size(AB,2); %# OF COLUMNS IN AB
%%%%FOWARD ELIMINATION SECTION
for J=1:R-1
[M,I]=max(abs(AB(J:R,J))); %M=MAXIMUM VALUE, I=LOCATION OF THE MAXIMUM VALUE IN THE 1ST ROW
temp=AB(J,:);
AB(J,:)=AB(I+(J-1),:);
AB(I+(J-1),:)=temp;
for i=(J+1):R;
if AB(i,J)~=0;
AB(i,:)=AB(i,:)-(AB(i,J)/AB(J,J))*AB(J,:);
end
end
end
%%%%BACKWARDS SUBSTITUTION
a(R)=AB(R,C)/AB(R,R);
for i=R-1:-1:1
a(i)=(AB(i,C)-AB(i,i+1:R)*a(i+1:R)’)/AB(i,i);
end
disp(a)
syms X
P=0;
for i=1:m;
TT=a(i)*X^(i-1); %T=INDIVIDUAL POLYNOMIAL TERMS
P=P+TT;
end
display(P)
%========END OF GAUSSIAN ELIMINATION=======%%%%%%%%
%STANDARD DEVIATION
Y_bar=mean(Y); %ADVERAGE OF y
St=sum((Y-Y_bar).^2);
SD=sqrt(St/(k-1)); %STANDARD DEVIATION
%STANDARD ERROR
for i=1:m;
T(:,i)=a(i)*X.^(i-1); %T=INDIVIDUAL POLYNOMIAL TERMS
end
for i=1:k
y_hat(i)=sum(T(i,:));
end
Sr=sum((Y-y_hat).^2);
Se=sqrt(Sr/(k-(n+1))); %STANDARD ERROR-Se
%COEFFICIENT OF DETERMINATION
Cd=(St-Sr)/St %COEFFICIENT OF DETERMINATION (r^2)
Cd = 1.0000
fprintf(‘For n=%d. Coefficient of Determination=%0.5fn’,n,Cd)
function [dydt] = Projectfunction(t,x,y)
Ic=1356; %kg-m^2
Mb=730; %kg
Mf=59; %kg
Mr=45; %kg
Kf=23000; %N/m
Ksf=18750; %N/m
Kr=16182; %N/m
Ksr=12574; %N/m
Bsf=100; %N*s/m
Bsr=100; %N*s/m
L1=1.45; %m
L2=1.39; %m
L3=0.67; %m
x1 = x(1); %x1=Xf
x2 = x(2); %x2=Xr
x3 = x(3); %x3=Xb
x4 = x(4); %x4=theta
y1 = y(1); %y1=Xf’=dXf/dt
y2 = y(2); %y2=Xr’=dXr/dt
y3 = y(3); %y3=Xb’=dXb/dt
y4 = y(4); %y4=theta’=dtheta/dt
dydt1 = (Ksf*((x3-(L1*x4)))-x1)+Bsf*((y3-(L1*y4)-y1)-(Kf*x1))/Mf;
dydt2 = (Ksr*((x3+(L2*x4))-x2)+Bsr*((y3+(L2*y4))-y2)-(Kr*x2))/Mr;
dydt3 = (Ksf*((x3-(L1*x4))-x1)+Bsf*((y3-(L1*y4))-y1)+Ksr*((x3+(L2*x4))-x2)+Bsr*((y3+(L2*y4))-y2)-(10*exp(-(5*t))))/Mb;
dydt4 = ((-(Ksf*(x1-(L1*x4))*L1)-(Bsf*(y1-(L1*y4))*L1)+(Ksr*(x2+(L2*x4))*L2)+(Bsr*(y2+(L2*y4))*L2)+((10*exp(-(5*t)))*L3)))/Ic;
[dydt] = [dydt1; dydt2; dydt3; dydt4];
end
% MfXf"=Ksf([Xb-(L1*theta)]-Xf)+Bsf([Xb’-(L1*theta’)-Xf’)-(Kf*Xf);
% MrXr"=Ksr([Xb+(L2*theta)]-Xr)+Bsr([Xb’+(L2*theta’)]-Xr’)-(Kr*Xr) ;
% MbXb"=Ksf([Xb-(L1*theta)]-Xf)+Bsf([Xb’-(L1*theta’)]-Xf’)+Ksr([Xb+(L2*theta)]-Xr)+Bsr([Xb’+(L2*theta’)]-Xr’)+fa(t);
% Ic*theta"={-[Ksf(Xf-(L1*theta))*L1]-[Bsf(Xf’-(L1*theta’))*L1]+[Ksr(Xr+(L2*theta))*L2]+[Bsr(Xr’+(L2*theta’))*L2]+[fa(t)*L3]}; I get this error when trying to solve these 4 second order differential equations using a program that solves them using Heun’s method and then Gaussian elimination to get a polynomial equation the represents the system. Previsouly posted for help, but the soluitions have symbolics and I need a singular soluition that represents all 4 equations. Does any one have a suggestion on how I can slove this? Is using the "function" with all 4 equations the best way to do this, or is there a nicer method for doing this?
clear,close,clc
%______________________________________________________________SOLUITION_2_Heun’s_Method_(for second order differential equations)_&__Least-Square_Nethod____________________________________________________________%
%4 Equations representing the system working with
% MfXf"=Ksf([Xb-(L1*theta)]-Xf)+Bsf([Xb’-(L1*theta’)-Xf’)-(Kf*Xf);
% MrXr"=Ksr([Xb+(L2*theta)]-Xr)+Bsr([Xb’+(L2*theta’)]-Xr’)-(Kr*Xr) ;
% MbXb"=Ksf([Xb-(L1*theta)]-Xf)+Bsf([Xb’-(L1*theta’)]-Xf’)+Ksr([Xb+(L2*theta)]-Xr)+Bsr([Xb’+(L2*theta’)]-Xr’)+fa(t);
% Ic*theta"={-[Ksf(Xf-(L1*theta))*L1]-[Bsf(Xf’-(L1*theta’))*L1]+[Ksr(Xr+(L2*theta))*L2]+[Bsr(Xr’+(L2*theta’))*L2]+[fa(t)*L3]};
%————————————————-SYSTEM_PARAMETERS———————————————————————————————————————————————————-
Ic=1356; %kg-m^2
Mb=730; %kg
Mf=59; %kg
Mr=45; %kg
Kf=23000; %N/m
Ksf=18750; %N/m
Kr=16182; %N/m
Ksr=12574; %N/m
Bsf=100; %N*s/m
Bsr=100; %N*s/m
L1=1.45; %m
L2=1.39; %m
L3=0.67; %m
t0=0; %time at the start
tm=20; %what value of (t time) you are ending at
t=t0:tm; % time from time start to time finish seconds
n=4; %order of the polynomial
%Initial Conditions-system at rest therefore x(0)=0 dXf/dt(0)=0 dXr/dt(0)=0 dXb/dt(0)=0 dtheta/dt(0)=0 ;
%time from 0 to 20 h=dx=5;
x0=0; %x at initial condition
y0=0; %y at initial condition
dx=5; %delta(x) or h
h=dx;
%==INPUT SECTION for Euler’s and Heun’s==%
fx=@(x,y,t)y;
fy=@(x,y,t)Projectfunction;
%==CALCULATIONS SECTION==%
tn=t0:h:tm;
xn(1) = x0;
yn(1) = y0;
for i=1:length(tn)
%==EULER’S METHOD
xn(i+1)=xn(i)+fx(xn(i),yn(i),tn(i))*h;
yn(i+1)=yn(i)+fy(xn(i),yn(i),tn(i))*h;
%==NEXT 3 LINES ARE FOR HEUN’S METHOD
tn(i+1)=tn(i)+h;
xn(i+1)=xn(i)+0.5*(fx(xn(i),yn(i),tn(i))+fx(xn(i+1),yn(i+1),tn(i+1)))*h;
yn(i+1)=yn(i)+0.5*(fy(xn(i),yn(i),tn(i))+fy(xn(i+1),yn(i+1),tn(i+1)))*h;
fprintf(‘t=%0.2ft y=%0.3ft z=%0.3fn’,tn(i),xn(i),yn(i))
end
%%%LEAST SQUARE METHOD-FINDS POLYNOMIAL FOR GIVEN DATA SET%%%%%
%INPUT SECTION for Least-Square
X=xn;
Y=yn;
%%__CALCULATIONS SECTION__%%
k=length(X); %NUMBER OF AVAILABLE DATA POINTS
m=n+1; %SIZE OF THE COEFFICENT MATRIX
A=zeros(m,m); %COEFFICENT MATRIX
for j=1:m
for i=1:m
A(j,i)=sum(X.^(i+j-2));
end
end
B=zeros(m,1); %FORCING FUNCTION VECTOR
for i=1:m;
B(i)=sum(Y.*X.^(i-1));
end
a1=AB %COEFFICIENTS FOR THE POLYNOMINAL–> y=a0+a1*x+a2*x^2….an*x^n CAN BE REPLACED BY GAUSSIAN ELIMINATION
%%%%%=========GAUSSIAN ELIMINATION TO FIND "a"========%%%%%%
%%%INPUT SECTION
%CALCULATION SECTION
AB=[A B]; %Augumentent matrix
R=size(AB,1); %# OF ROWS IN AB
C=size(AB,2); %# OF COLUMNS IN AB
%%%%FOWARD ELIMINATION SECTION
for J=1:R-1
[M,I]=max(abs(AB(J:R,J))); %M=MAXIMUM VALUE, I=LOCATION OF THE MAXIMUM VALUE IN THE 1ST ROW
temp=AB(J,:);
AB(J,:)=AB(I+(J-1),:);
AB(I+(J-1),:)=temp;
for i=(J+1):R;
if AB(i,J)~=0;
AB(i,:)=AB(i,:)-(AB(i,J)/AB(J,J))*AB(J,:);
end
end
end
%%%%BACKWARDS SUBSTITUTION
a(R)=AB(R,C)/AB(R,R);
for i=R-1:-1:1
a(i)=(AB(i,C)-AB(i,i+1:R)*a(i+1:R)’)/AB(i,i);
end
disp(a)
syms X
P=0;
for i=1:m;
TT=a(i)*X^(i-1); %T=INDIVIDUAL POLYNOMIAL TERMS
P=P+TT;
end
display(P)
%========END OF GAUSSIAN ELIMINATION=======%%%%%%%%
%STANDARD DEVIATION
Y_bar=mean(Y); %ADVERAGE OF y
St=sum((Y-Y_bar).^2);
SD=sqrt(St/(k-1)); %STANDARD DEVIATION
%STANDARD ERROR
for i=1:m;
T(:,i)=a(i)*X.^(i-1); %T=INDIVIDUAL POLYNOMIAL TERMS
end
for i=1:k
y_hat(i)=sum(T(i,:));
end
Sr=sum((Y-y_hat).^2);
Se=sqrt(Sr/(k-(n+1))); %STANDARD ERROR-Se
%COEFFICIENT OF DETERMINATION
Cd=(St-Sr)/St %COEFFICIENT OF DETERMINATION (r^2)
Cd = 1.0000
fprintf(‘For n=%d. Coefficient of Determination=%0.5fn’,n,Cd)
function [dydt] = Projectfunction(t,x,y)
Ic=1356; %kg-m^2
Mb=730; %kg
Mf=59; %kg
Mr=45; %kg
Kf=23000; %N/m
Ksf=18750; %N/m
Kr=16182; %N/m
Ksr=12574; %N/m
Bsf=100; %N*s/m
Bsr=100; %N*s/m
L1=1.45; %m
L2=1.39; %m
L3=0.67; %m
x1 = x(1); %x1=Xf
x2 = x(2); %x2=Xr
x3 = x(3); %x3=Xb
x4 = x(4); %x4=theta
y1 = y(1); %y1=Xf’=dXf/dt
y2 = y(2); %y2=Xr’=dXr/dt
y3 = y(3); %y3=Xb’=dXb/dt
y4 = y(4); %y4=theta’=dtheta/dt
dydt1 = (Ksf*((x3-(L1*x4)))-x1)+Bsf*((y3-(L1*y4)-y1)-(Kf*x1))/Mf;
dydt2 = (Ksr*((x3+(L2*x4))-x2)+Bsr*((y3+(L2*y4))-y2)-(Kr*x2))/Mr;
dydt3 = (Ksf*((x3-(L1*x4))-x1)+Bsf*((y3-(L1*y4))-y1)+Ksr*((x3+(L2*x4))-x2)+Bsr*((y3+(L2*y4))-y2)-(10*exp(-(5*t))))/Mb;
dydt4 = ((-(Ksf*(x1-(L1*x4))*L1)-(Bsf*(y1-(L1*y4))*L1)+(Ksr*(x2+(L2*x4))*L2)+(Bsr*(y2+(L2*y4))*L2)+((10*exp(-(5*t)))*L3)))/Ic;
[dydt] = [dydt1; dydt2; dydt3; dydt4];
end
% MfXf"=Ksf([Xb-(L1*theta)]-Xf)+Bsf([Xb’-(L1*theta’)-Xf’)-(Kf*Xf);
% MrXr"=Ksr([Xb+(L2*theta)]-Xr)+Bsr([Xb’+(L2*theta’)]-Xr’)-(Kr*Xr) ;
% MbXb"=Ksf([Xb-(L1*theta)]-Xf)+Bsf([Xb’-(L1*theta’)]-Xf’)+Ksr([Xb+(L2*theta)]-Xr)+Bsr([Xb’+(L2*theta’)]-Xr’)+fa(t);
% Ic*theta"={-[Ksf(Xf-(L1*theta))*L1]-[Bsf(Xf’-(L1*theta’))*L1]+[Ksr(Xr+(L2*theta))*L2]+[Bsr(Xr’+(L2*theta’))*L2]+[fa(t)*L3]}; polynomial from heun’s method, solving 4 2nd ode MATLAB Answers — New Questions
HOW TO GENERATE XLSX files from .prn files
Post Content Post Content the above pic is in .prn format, i want to convert these .prn file to xlsx file MATLAB Answers — New Questions
matrix normalization in matlab
hi.. i want normalize a matrix (129 x 128)..please help me with matlab codeshi.. i want normalize a matrix (129 x 128)..please help me with matlab codes hi.. i want normalize a matrix (129 x 128)..please help me with matlab codes normalization, matrix MATLAB Answers — New Questions
Determining optimal cut off frequency
Hello,
I have some motion capture data that I need to filter before differentiating to get velocity and acceleration. I have been told to filter at a range of frequencies and then calculate the RMSD between the original and filtered data. I want to used a forth order low pass butterworth filter. I have managed to do so but do not understand how I then interpret the plot to decide on my optimal filtering frequency. I have seen some previous posts mention ‘fft’ but do not understand what this does and if I should be using it.
This is my function:
function plot_rmsd_vs_cutoff(data, fs, f_min, f_max, num_points)
% Plot RMSD against cut-off frequency for given data
% Data and sampling frequency
% data: input data
% fs: sampling frequency
% Frequency range
% f_min: minimum cut-off frequency
% f_max: maximum cut-off frequency
% num_points: number of points in the frequency range
% Create a vector of cut-off frequencies
cutoff_freqs = linspace(f_min, f_max, num_points);
% Initialize RMSD vector
rmsd_values = zeros(size(cutoff_freqs));
for i = 1:length(cutoff_freqs)
% Filter data
[b, a] = butter(4, cutoff_freqs(i)/(fs/2), ‘low’); % Example: 4th order lowpass Butterworth
filtered_data = filtfilt(b, a, data);
% Calculate RMSD
rmsd_values(i) = rms(data – filtered_data);
end
% Plot RMSD against cut-off frequency
plot(cutoff_freqs, rmsd_values);
xlabel(‘Cut-off Frequency (Hz)’);
ylabel(‘RMSD’);
title(‘RMSD vs Cut-off Frequency’);
end
This is how I have used it in my code:
% Call the function
plot_rmsd_vs_cutoff(data, fs, 1, 50, 50);
I have attached my data and the output I have got.
Many thanks for any help.Hello,
I have some motion capture data that I need to filter before differentiating to get velocity and acceleration. I have been told to filter at a range of frequencies and then calculate the RMSD between the original and filtered data. I want to used a forth order low pass butterworth filter. I have managed to do so but do not understand how I then interpret the plot to decide on my optimal filtering frequency. I have seen some previous posts mention ‘fft’ but do not understand what this does and if I should be using it.
This is my function:
function plot_rmsd_vs_cutoff(data, fs, f_min, f_max, num_points)
% Plot RMSD against cut-off frequency for given data
% Data and sampling frequency
% data: input data
% fs: sampling frequency
% Frequency range
% f_min: minimum cut-off frequency
% f_max: maximum cut-off frequency
% num_points: number of points in the frequency range
% Create a vector of cut-off frequencies
cutoff_freqs = linspace(f_min, f_max, num_points);
% Initialize RMSD vector
rmsd_values = zeros(size(cutoff_freqs));
for i = 1:length(cutoff_freqs)
% Filter data
[b, a] = butter(4, cutoff_freqs(i)/(fs/2), ‘low’); % Example: 4th order lowpass Butterworth
filtered_data = filtfilt(b, a, data);
% Calculate RMSD
rmsd_values(i) = rms(data – filtered_data);
end
% Plot RMSD against cut-off frequency
plot(cutoff_freqs, rmsd_values);
xlabel(‘Cut-off Frequency (Hz)’);
ylabel(‘RMSD’);
title(‘RMSD vs Cut-off Frequency’);
end
This is how I have used it in my code:
% Call the function
plot_rmsd_vs_cutoff(data, fs, 1, 50, 50);
I have attached my data and the output I have got.
Many thanks for any help. Hello,
I have some motion capture data that I need to filter before differentiating to get velocity and acceleration. I have been told to filter at a range of frequencies and then calculate the RMSD between the original and filtered data. I want to used a forth order low pass butterworth filter. I have managed to do so but do not understand how I then interpret the plot to decide on my optimal filtering frequency. I have seen some previous posts mention ‘fft’ but do not understand what this does and if I should be using it.
This is my function:
function plot_rmsd_vs_cutoff(data, fs, f_min, f_max, num_points)
% Plot RMSD against cut-off frequency for given data
% Data and sampling frequency
% data: input data
% fs: sampling frequency
% Frequency range
% f_min: minimum cut-off frequency
% f_max: maximum cut-off frequency
% num_points: number of points in the frequency range
% Create a vector of cut-off frequencies
cutoff_freqs = linspace(f_min, f_max, num_points);
% Initialize RMSD vector
rmsd_values = zeros(size(cutoff_freqs));
for i = 1:length(cutoff_freqs)
% Filter data
[b, a] = butter(4, cutoff_freqs(i)/(fs/2), ‘low’); % Example: 4th order lowpass Butterworth
filtered_data = filtfilt(b, a, data);
% Calculate RMSD
rmsd_values(i) = rms(data – filtered_data);
end
% Plot RMSD against cut-off frequency
plot(cutoff_freqs, rmsd_values);
xlabel(‘Cut-off Frequency (Hz)’);
ylabel(‘RMSD’);
title(‘RMSD vs Cut-off Frequency’);
end
This is how I have used it in my code:
% Call the function
plot_rmsd_vs_cutoff(data, fs, 1, 50, 50);
I have attached my data and the output I have got.
Many thanks for any help. cut off frequency, butterworth filter, filter, rmsd MATLAB Answers — New Questions
MATLAB crashes on macOS Sonoma when clearing a figure.
I am repeatedly plotting on the same figure object (so that a long-running code doesn’t continuously steal focus for each new figure) and using clf(fig) to clear the figure each time. However, this consistently causes MATLAB to crash on my Mac.
I’ve seen many forum posts on this type of behavior when the figure closes, but nothing on clf specifically. I tried a few solutions:
Adding a line to my startup.m file (https://www.mathworks.com/matlabcentral/answers/2039461-matlab-freezes-i-am-using-mac-apple-m2-max-osx-sonoma, https://www.mathworks.com/matlabcentral/answers/1808195-matlab-r2022a-freezes-on-macos-monterey-12-5-1-when-closing-a-figure#answer_1324680)
Changing clf(fig) to delete(fig) or reset(fig)
Adding pause(0.1) or pause(1) before the clf (this resulted in a crash after ~20 and ~30 figures, respectively, instead of just 1 without it).
I set figure visibility to ‘off’. This tentatively seems to allow me to plot without crashing, but obviously with the limitation of not being able to see the plots as they’re generated! For some plots this is ok for me, for others it is not, such as when I’m plotting movies and want to verify that they’re accurate before wasting time plotting each frame.
I am on an M1 Mac 16GB RAM running MacOS Sonoma 14.5. Is there anything to be done so I can view my figures while plotting them?I am repeatedly plotting on the same figure object (so that a long-running code doesn’t continuously steal focus for each new figure) and using clf(fig) to clear the figure each time. However, this consistently causes MATLAB to crash on my Mac.
I’ve seen many forum posts on this type of behavior when the figure closes, but nothing on clf specifically. I tried a few solutions:
Adding a line to my startup.m file (https://www.mathworks.com/matlabcentral/answers/2039461-matlab-freezes-i-am-using-mac-apple-m2-max-osx-sonoma, https://www.mathworks.com/matlabcentral/answers/1808195-matlab-r2022a-freezes-on-macos-monterey-12-5-1-when-closing-a-figure#answer_1324680)
Changing clf(fig) to delete(fig) or reset(fig)
Adding pause(0.1) or pause(1) before the clf (this resulted in a crash after ~20 and ~30 figures, respectively, instead of just 1 without it).
I set figure visibility to ‘off’. This tentatively seems to allow me to plot without crashing, but obviously with the limitation of not being able to see the plots as they’re generated! For some plots this is ok for me, for others it is not, such as when I’m plotting movies and want to verify that they’re accurate before wasting time plotting each frame.
I am on an M1 Mac 16GB RAM running MacOS Sonoma 14.5. Is there anything to be done so I can view my figures while plotting them? I am repeatedly plotting on the same figure object (so that a long-running code doesn’t continuously steal focus for each new figure) and using clf(fig) to clear the figure each time. However, this consistently causes MATLAB to crash on my Mac.
I’ve seen many forum posts on this type of behavior when the figure closes, but nothing on clf specifically. I tried a few solutions:
Adding a line to my startup.m file (https://www.mathworks.com/matlabcentral/answers/2039461-matlab-freezes-i-am-using-mac-apple-m2-max-osx-sonoma, https://www.mathworks.com/matlabcentral/answers/1808195-matlab-r2022a-freezes-on-macos-monterey-12-5-1-when-closing-a-figure#answer_1324680)
Changing clf(fig) to delete(fig) or reset(fig)
Adding pause(0.1) or pause(1) before the clf (this resulted in a crash after ~20 and ~30 figures, respectively, instead of just 1 without it).
I set figure visibility to ‘off’. This tentatively seems to allow me to plot without crashing, but obviously with the limitation of not being able to see the plots as they’re generated! For some plots this is ok for me, for others it is not, such as when I’m plotting movies and want to verify that they’re accurate before wasting time plotting each frame.
I am on an M1 Mac 16GB RAM running MacOS Sonoma 14.5. Is there anything to be done so I can view my figures while plotting them? mac, sonoma, plot, plotting, figure, crash MATLAB Answers — New Questions
How do I copy figure properties from one to another?
I would like to copy the properties from Fig 1 to Fig 2. How can that be done?I would like to copy the properties from Fig 1 to Fig 2. How can that be done? I would like to copy the properties from Fig 1 to Fig 2. How can that be done? star strider, walter roberson, torsten, dyuman joshi MATLAB Answers — New Questions
Vector field graph from a data file.
I am totally new to Matlab. I have data on file. I need to draw a 2-D vector field graph of the data.
I would appreciate detailed instructions as this is my first attempt as using Matlab.
Much apprrciate any advice.
RegardsI am totally new to Matlab. I have data on file. I need to draw a 2-D vector field graph of the data.
I would appreciate detailed instructions as this is my first attempt as using Matlab.
Much apprrciate any advice.
Regards I am totally new to Matlab. I have data on file. I need to draw a 2-D vector field graph of the data.
I would appreciate detailed instructions as this is my first attempt as using Matlab.
Much apprrciate any advice.
Regards vector field graph MATLAB Answers — New Questions
How to implement MultiStart to find a good fit of two curves at the same time with real data such as our curves are governed by an ODE system?
% Set up the problem for MultiStart
problem = createOptimProblem(‘lsqcurvefit’,’x0′,k0,’objective’,@simulatedhs,…
‘lb’,zeros(size(k0)),’xdata’,tforward ,’ydata’,[Hdata,HSdata] );
ms = MultiStart;
[k,fval,Exitflag,Output,Solutions] = run(ms,problem,50);
simulated_data = simulatedhs(k,tforward);
X=simulated_data(:,1);
Z=simulated_data(:,2);
%plot the result
figure(5)
plot(tforward,Hdata ,tforward,X)
plot(tforward,Hdata,tforward,Y)
legend(‘Data’,’Fitted result’)% Set up the problem for MultiStart
problem = createOptimProblem(‘lsqcurvefit’,’x0′,k0,’objective’,@simulatedhs,…
‘lb’,zeros(size(k0)),’xdata’,tforward ,’ydata’,[Hdata,HSdata] );
ms = MultiStart;
[k,fval,Exitflag,Output,Solutions] = run(ms,problem,50);
simulated_data = simulatedhs(k,tforward);
X=simulated_data(:,1);
Z=simulated_data(:,2);
%plot the result
figure(5)
plot(tforward,Hdata ,tforward,X)
plot(tforward,Hdata,tforward,Y)
legend(‘Data’,’Fitted result’) % Set up the problem for MultiStart
problem = createOptimProblem(‘lsqcurvefit’,’x0′,k0,’objective’,@simulatedhs,…
‘lb’,zeros(size(k0)),’xdata’,tforward ,’ydata’,[Hdata,HSdata] );
ms = MultiStart;
[k,fval,Exitflag,Output,Solutions] = run(ms,problem,50);
simulated_data = simulatedhs(k,tforward);
X=simulated_data(:,1);
Z=simulated_data(:,2);
%plot the result
figure(5)
plot(tforward,Hdata ,tforward,X)
plot(tforward,Hdata,tforward,Y)
legend(‘Data’,’Fitted result’) parameter estimation, curve fitting, multistart, oprimization, global minimum MATLAB Answers — New Questions
Parallel Workers Sometimes Can’t Access Function
I’m building an app that uses the Parallel Processing toolbox to run Simulink models in parallel. I create a list of FevalFuture objects for the workers, and assign their tasks with parfeval on a function I wrote. I don’t have my code on me at the moment, but it’s basically
for p = 1:numel(taskList)
futures(p) = parfeval(appName.parallelSimulationTask(taskList{p}));
end
It was working at one point, but now it takes 3 tries to successfully run.
After the pool is first opened, none of the tasks run at all. They all immediately return a MATLAB:class:MethodRestricted error saying they cannot access the function I’m sending them.
The second time I run my app, with the pool still open, only some of them fail with the same error. The rest run successfully.
The third time and then on, everything runs perfectly with no errors.
Does anyone have any idea why parallel workers would sometimes be unable to access a function?
I don’t have my code on me at the moment, but I can add it later if necessary.I’m building an app that uses the Parallel Processing toolbox to run Simulink models in parallel. I create a list of FevalFuture objects for the workers, and assign their tasks with parfeval on a function I wrote. I don’t have my code on me at the moment, but it’s basically
for p = 1:numel(taskList)
futures(p) = parfeval(appName.parallelSimulationTask(taskList{p}));
end
It was working at one point, but now it takes 3 tries to successfully run.
After the pool is first opened, none of the tasks run at all. They all immediately return a MATLAB:class:MethodRestricted error saying they cannot access the function I’m sending them.
The second time I run my app, with the pool still open, only some of them fail with the same error. The rest run successfully.
The third time and then on, everything runs perfectly with no errors.
Does anyone have any idea why parallel workers would sometimes be unable to access a function?
I don’t have my code on me at the moment, but I can add it later if necessary. I’m building an app that uses the Parallel Processing toolbox to run Simulink models in parallel. I create a list of FevalFuture objects for the workers, and assign their tasks with parfeval on a function I wrote. I don’t have my code on me at the moment, but it’s basically
for p = 1:numel(taskList)
futures(p) = parfeval(appName.parallelSimulationTask(taskList{p}));
end
It was working at one point, but now it takes 3 tries to successfully run.
After the pool is first opened, none of the tasks run at all. They all immediately return a MATLAB:class:MethodRestricted error saying they cannot access the function I’m sending them.
The second time I run my app, with the pool still open, only some of them fail with the same error. The rest run successfully.
The third time and then on, everything runs perfectly with no errors.
Does anyone have any idea why parallel workers would sometimes be unable to access a function?
I don’t have my code on me at the moment, but I can add it later if necessary. parallel computing, simulink, methodrestricted MATLAB Answers — New Questions
How to get “Clean” edges on a surface plot?
Hello All,
I am trying to plot a surface using the surf() command with some imported shape data from a CSV. The shape in question is created by revolving our data from 0 to 180 degrees. The data starts out as axial position and a corresponding radius. Essentially, it’s a half-pipe with asymmetrically tapered ends.
I’ve been able to import my data, revolve it, and use meshgrid() and griddata() to create the Z coordinate matrix. However, as you can see from my attached screenshot, there are "flats" at the ends of the revolved shape. I have a feeling this has something to do with the interpolation, but I’m not very familiar with this type of stuff. I can’t seem to get rid of the flat protrusions.
In my attempts to rectify this, the closest I could get was ending up with jagged edges instead. But this won’t work either since this shape data is going to be imported into a Simscape model, and we want it to be as true to life as possible (no flat protrusions and no jagged edges).
Any ideas? Data attached as a text file (wouldn’t let me attach a CSV) and code pasted below.
Thanks Everyone!
GS = readtable(‘GSDataEdited.csv’);
GS = table2array(GS);
GSx = GS(:, 1);
GSrad = GS(:, 2);
% Define the angle step (in degrees)
angle_step = 7.5;
all_points = [];
% Loop through angles from 0 to 180 degrees
for angle = 0:angle_step:180
% Convert angle to radians
theta = deg2rad(angle);
% Create rotation matrix for current angle
R = [1 0 0; 0 cos(theta) -sin(theta); 0 sin(theta) cos(theta)];
% Rotate the coordinates
rotated_coords = R * [GSx’; GSrad’; zeros(size(GSx’))];
% Append the rotated coordinates to the matrix
all_points = [all_points, rotated_coords];
end
all_points = all_points’;
GSx = all_points(:, 1);
GSy = all_points(:, 2);
GSz = all_points(:, 3);
GSall = [GSx,GSy,GSz;GSx,GSy,-GSz];
GSall = unique(GSall, ‘rows’);
% Define grid for interpolation
[GSX,GSY] = meshgrid(min(GSx):1:max(GSx), min(GSy):1:max(GSy)); % Define the grid spacing
% Interpolate data onto grid
ZVect = griddata(GSx, GSy, GSz, GSX, GSY, ‘linear’);
XVect = GSX(1, :);
YVect = GSY(:, 1);
ZVect(isnan(ZVect))=0;
surf(XVect, YVect, ZVect, ‘EdgeColor’, ‘none’)Hello All,
I am trying to plot a surface using the surf() command with some imported shape data from a CSV. The shape in question is created by revolving our data from 0 to 180 degrees. The data starts out as axial position and a corresponding radius. Essentially, it’s a half-pipe with asymmetrically tapered ends.
I’ve been able to import my data, revolve it, and use meshgrid() and griddata() to create the Z coordinate matrix. However, as you can see from my attached screenshot, there are "flats" at the ends of the revolved shape. I have a feeling this has something to do with the interpolation, but I’m not very familiar with this type of stuff. I can’t seem to get rid of the flat protrusions.
In my attempts to rectify this, the closest I could get was ending up with jagged edges instead. But this won’t work either since this shape data is going to be imported into a Simscape model, and we want it to be as true to life as possible (no flat protrusions and no jagged edges).
Any ideas? Data attached as a text file (wouldn’t let me attach a CSV) and code pasted below.
Thanks Everyone!
GS = readtable(‘GSDataEdited.csv’);
GS = table2array(GS);
GSx = GS(:, 1);
GSrad = GS(:, 2);
% Define the angle step (in degrees)
angle_step = 7.5;
all_points = [];
% Loop through angles from 0 to 180 degrees
for angle = 0:angle_step:180
% Convert angle to radians
theta = deg2rad(angle);
% Create rotation matrix for current angle
R = [1 0 0; 0 cos(theta) -sin(theta); 0 sin(theta) cos(theta)];
% Rotate the coordinates
rotated_coords = R * [GSx’; GSrad’; zeros(size(GSx’))];
% Append the rotated coordinates to the matrix
all_points = [all_points, rotated_coords];
end
all_points = all_points’;
GSx = all_points(:, 1);
GSy = all_points(:, 2);
GSz = all_points(:, 3);
GSall = [GSx,GSy,GSz;GSx,GSy,-GSz];
GSall = unique(GSall, ‘rows’);
% Define grid for interpolation
[GSX,GSY] = meshgrid(min(GSx):1:max(GSx), min(GSy):1:max(GSy)); % Define the grid spacing
% Interpolate data onto grid
ZVect = griddata(GSx, GSy, GSz, GSX, GSY, ‘linear’);
XVect = GSX(1, :);
YVect = GSY(:, 1);
ZVect(isnan(ZVect))=0;
surf(XVect, YVect, ZVect, ‘EdgeColor’, ‘none’) Hello All,
I am trying to plot a surface using the surf() command with some imported shape data from a CSV. The shape in question is created by revolving our data from 0 to 180 degrees. The data starts out as axial position and a corresponding radius. Essentially, it’s a half-pipe with asymmetrically tapered ends.
I’ve been able to import my data, revolve it, and use meshgrid() and griddata() to create the Z coordinate matrix. However, as you can see from my attached screenshot, there are "flats" at the ends of the revolved shape. I have a feeling this has something to do with the interpolation, but I’m not very familiar with this type of stuff. I can’t seem to get rid of the flat protrusions.
In my attempts to rectify this, the closest I could get was ending up with jagged edges instead. But this won’t work either since this shape data is going to be imported into a Simscape model, and we want it to be as true to life as possible (no flat protrusions and no jagged edges).
Any ideas? Data attached as a text file (wouldn’t let me attach a CSV) and code pasted below.
Thanks Everyone!
GS = readtable(‘GSDataEdited.csv’);
GS = table2array(GS);
GSx = GS(:, 1);
GSrad = GS(:, 2);
% Define the angle step (in degrees)
angle_step = 7.5;
all_points = [];
% Loop through angles from 0 to 180 degrees
for angle = 0:angle_step:180
% Convert angle to radians
theta = deg2rad(angle);
% Create rotation matrix for current angle
R = [1 0 0; 0 cos(theta) -sin(theta); 0 sin(theta) cos(theta)];
% Rotate the coordinates
rotated_coords = R * [GSx’; GSrad’; zeros(size(GSx’))];
% Append the rotated coordinates to the matrix
all_points = [all_points, rotated_coords];
end
all_points = all_points’;
GSx = all_points(:, 1);
GSy = all_points(:, 2);
GSz = all_points(:, 3);
GSall = [GSx,GSy,GSz;GSx,GSy,-GSz];
GSall = unique(GSall, ‘rows’);
% Define grid for interpolation
[GSX,GSY] = meshgrid(min(GSx):1:max(GSx), min(GSy):1:max(GSy)); % Define the grid spacing
% Interpolate data onto grid
ZVect = griddata(GSx, GSy, GSz, GSX, GSY, ‘linear’);
XVect = GSX(1, :);
YVect = GSY(:, 1);
ZVect(isnan(ZVect))=0;
surf(XVect, YVect, ZVect, ‘EdgeColor’, ‘none’) matlab, grid surface, surface, interpolation MATLAB Answers — New Questions
how to graph vector fields containing scalar
I’m trying to graph some vector fields .
F(x,y,z)-<1,2,z>
F(x,y)=<0.3, -0,4)
my code is look like this
>> [x,y,z]=meshgrid(-2:2,-2:2,-2:2);
>> u=1;
>> v=2;
>> s=z;
>> quiver(x,y,z,u,v,s)
Second one is similar.
>> [x,y,]=meshgrid(-2:2,-2:2);
>> u=0.3;
>> v=-0.4;
>> quiver(x,y, u,v )
I tried to use ones(size(v)) function but it doens’t work.
Any help would be helpful. Thank youI’m trying to graph some vector fields .
F(x,y,z)-<1,2,z>
F(x,y)=<0.3, -0,4)
my code is look like this
>> [x,y,z]=meshgrid(-2:2,-2:2,-2:2);
>> u=1;
>> v=2;
>> s=z;
>> quiver(x,y,z,u,v,s)
Second one is similar.
>> [x,y,]=meshgrid(-2:2,-2:2);
>> u=0.3;
>> v=-0.4;
>> quiver(x,y, u,v )
I tried to use ones(size(v)) function but it doens’t work.
Any help would be helpful. Thank you I’m trying to graph some vector fields .
F(x,y,z)-<1,2,z>
F(x,y)=<0.3, -0,4)
my code is look like this
>> [x,y,z]=meshgrid(-2:2,-2:2,-2:2);
>> u=1;
>> v=2;
>> s=z;
>> quiver(x,y,z,u,v,s)
Second one is similar.
>> [x,y,]=meshgrid(-2:2,-2:2);
>> u=0.3;
>> v=-0.4;
>> quiver(x,y, u,v )
I tried to use ones(size(v)) function but it doens’t work.
Any help would be helpful. Thank you vector field, vector, graph, plot MATLAB Answers — New Questions
Matlab crash if i connect MotoHawk
How do I generate a native crash dump for MATLAB on a WINDOWS?
It’s show this: MATLAB crash file:C:UserscasperAppDataLocalTempmatlab_crash_dump.18464-1:
——————————————————————————–
Unknown exception 0xe0434352 detected at 2024-08-02 12:48:46 +0300
——————————————————————————–
Configuration:
Crash Decoding : Disabled – No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : windows-1252
Deployed : false
Graphics Driver : Unknown hardware
Graphics card 1 : Intel Corporation ( 0x8086 ) Intel(R) UHD Graphics Version 27.20.100.9365 (2021-3-10)
Java Version : Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
MATLAB Architecture : win64
MATLAB Entitlement ID : 3514034
MATLAB Root : C:Program FilesMATLABR2020b
MATLAB Version : 9.9.0.2037887 (R2020b) Update 8
OpenGL : hardware
Operating System : Microsoft Windows 11 Home Single Language
Process ID : 18464
Processor ID : x86 Family 6 Model 126 Stepping 5, GenuineIntel
Session Key : 1a6fb761-06c5-4afa-9961-e6d8bf9d25a4
Window System : Version 10.0 (Build 22631)
Fault Count: 1
Abnormal termination:
Unknown exception 0xe0434352
Current Thread: ‘MCR 0 interpreter thread’ id 21248
Register State (from fault):
RAX = 00007ffdccca63e8 RBX = 000000a3a84f3d60
RCX = 000000a3a84f29d0 RDX = 000000a3a84f3530
RSP = 000000a3a84f2150 RBP = 000000a3a84f2830
RSI = 000000a3a84f4b60 RDI = 000000a3a84f2fe0
R8 = 0000000000000081 R9 = 000000a3a84f19f0
R10 = 00007ffde438e866 R11 = 000000a3a84f29d0
R12 = 0000000000000000 R13 = 000000a3a84f22b8
R14 = 0000000000000002 R15 = 000000a3a84f3148
RIP = 00007ffde1a4fabc EFL = 00000206
CS = 0033 FS = 0053 GS = 002b
Stack Trace (from fault):
[ 0] 0x00007ffde1a4fabc C:WINDOWSSystem32KERNELBASE.dll+00391868 RaiseException+00000108
[ 1] 0x00007ffdcdc32743 C:WINDOWSSYSTEM32VCRUNTIME140_1_CLR0400.dll+00010051 _NLG_Return2+00005619
[ 2] 0x00007ffde4414896 C:WINDOWSSYSTEM32ntdll.dll+00673942 RtlCaptureContext2+00001190
[ 3] 0x00007ffdcc4ae012 C:WindowsMicrosoft.NETFramework64v4.0.30319clr.dll+00319506 StrongNameTokenFromPublicKey+00192754
[ 4] 0x00007ffdcc4c5e56 C:WindowsMicrosoft.NETFramework64v4.0.30319clr.dll+00417366 StrongNameTokenFromPublicKey+00290614
[ 5] 0x00007ffdcc49891b C:WindowsMicrosoft.NETFramework64v4.0.30319clr.dll+00231707 StrongNameTokenFromPublicKey+00104955
[ 6] 0x00007ffdcc5ee7b5 C:WindowsMicrosoft.NETFramework64v4.0.30319clr.dll+01632181 DllCanUnloadNowInternal+00011525
[ 7] 0x00007ffd6ce31ce7 <unknown-module>+00000000
[ 8] 0x00007ffdd90f4238 C:Program Files (x86)WoodwardMCSMotoHawk2020b_sp5.2718BlocksMainmotohawk_sfun_check_license.mexw64+00016952 mexFunction+00012856
[ 9] 0x00007ffdd90f422c C:Program Files (x86)WoodwardMCSMotoHawk2020b_sp5.2718BlocksMainmotohawk_sfun_check_license.mexw64+00016940 mexFunction+00012844
[ 10] 0x0000000000000001 <unknown-module>+00000000
This error was detected while a MEX-file was running. If the MEX-file
is not an official MathWorks function, please examine its source code
for errors. Please consult the External Interfaces Guide for information
on debugging MEX-files.How do I generate a native crash dump for MATLAB on a WINDOWS?
It’s show this: MATLAB crash file:C:UserscasperAppDataLocalTempmatlab_crash_dump.18464-1:
——————————————————————————–
Unknown exception 0xe0434352 detected at 2024-08-02 12:48:46 +0300
——————————————————————————–
Configuration:
Crash Decoding : Disabled – No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : windows-1252
Deployed : false
Graphics Driver : Unknown hardware
Graphics card 1 : Intel Corporation ( 0x8086 ) Intel(R) UHD Graphics Version 27.20.100.9365 (2021-3-10)
Java Version : Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
MATLAB Architecture : win64
MATLAB Entitlement ID : 3514034
MATLAB Root : C:Program FilesMATLABR2020b
MATLAB Version : 9.9.0.2037887 (R2020b) Update 8
OpenGL : hardware
Operating System : Microsoft Windows 11 Home Single Language
Process ID : 18464
Processor ID : x86 Family 6 Model 126 Stepping 5, GenuineIntel
Session Key : 1a6fb761-06c5-4afa-9961-e6d8bf9d25a4
Window System : Version 10.0 (Build 22631)
Fault Count: 1
Abnormal termination:
Unknown exception 0xe0434352
Current Thread: ‘MCR 0 interpreter thread’ id 21248
Register State (from fault):
RAX = 00007ffdccca63e8 RBX = 000000a3a84f3d60
RCX = 000000a3a84f29d0 RDX = 000000a3a84f3530
RSP = 000000a3a84f2150 RBP = 000000a3a84f2830
RSI = 000000a3a84f4b60 RDI = 000000a3a84f2fe0
R8 = 0000000000000081 R9 = 000000a3a84f19f0
R10 = 00007ffde438e866 R11 = 000000a3a84f29d0
R12 = 0000000000000000 R13 = 000000a3a84f22b8
R14 = 0000000000000002 R15 = 000000a3a84f3148
RIP = 00007ffde1a4fabc EFL = 00000206
CS = 0033 FS = 0053 GS = 002b
Stack Trace (from fault):
[ 0] 0x00007ffde1a4fabc C:WINDOWSSystem32KERNELBASE.dll+00391868 RaiseException+00000108
[ 1] 0x00007ffdcdc32743 C:WINDOWSSYSTEM32VCRUNTIME140_1_CLR0400.dll+00010051 _NLG_Return2+00005619
[ 2] 0x00007ffde4414896 C:WINDOWSSYSTEM32ntdll.dll+00673942 RtlCaptureContext2+00001190
[ 3] 0x00007ffdcc4ae012 C:WindowsMicrosoft.NETFramework64v4.0.30319clr.dll+00319506 StrongNameTokenFromPublicKey+00192754
[ 4] 0x00007ffdcc4c5e56 C:WindowsMicrosoft.NETFramework64v4.0.30319clr.dll+00417366 StrongNameTokenFromPublicKey+00290614
[ 5] 0x00007ffdcc49891b C:WindowsMicrosoft.NETFramework64v4.0.30319clr.dll+00231707 StrongNameTokenFromPublicKey+00104955
[ 6] 0x00007ffdcc5ee7b5 C:WindowsMicrosoft.NETFramework64v4.0.30319clr.dll+01632181 DllCanUnloadNowInternal+00011525
[ 7] 0x00007ffd6ce31ce7 <unknown-module>+00000000
[ 8] 0x00007ffdd90f4238 C:Program Files (x86)WoodwardMCSMotoHawk2020b_sp5.2718BlocksMainmotohawk_sfun_check_license.mexw64+00016952 mexFunction+00012856
[ 9] 0x00007ffdd90f422c C:Program Files (x86)WoodwardMCSMotoHawk2020b_sp5.2718BlocksMainmotohawk_sfun_check_license.mexw64+00016940 mexFunction+00012844
[ 10] 0x0000000000000001 <unknown-module>+00000000
This error was detected while a MEX-file was running. If the MEX-file
is not an official MathWorks function, please examine its source code
for errors. Please consult the External Interfaces Guide for information
on debugging MEX-files. How do I generate a native crash dump for MATLAB on a WINDOWS?
It’s show this: MATLAB crash file:C:UserscasperAppDataLocalTempmatlab_crash_dump.18464-1:
——————————————————————————–
Unknown exception 0xe0434352 detected at 2024-08-02 12:48:46 +0300
——————————————————————————–
Configuration:
Crash Decoding : Disabled – No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : windows-1252
Deployed : false
Graphics Driver : Unknown hardware
Graphics card 1 : Intel Corporation ( 0x8086 ) Intel(R) UHD Graphics Version 27.20.100.9365 (2021-3-10)
Java Version : Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
MATLAB Architecture : win64
MATLAB Entitlement ID : 3514034
MATLAB Root : C:Program FilesMATLABR2020b
MATLAB Version : 9.9.0.2037887 (R2020b) Update 8
OpenGL : hardware
Operating System : Microsoft Windows 11 Home Single Language
Process ID : 18464
Processor ID : x86 Family 6 Model 126 Stepping 5, GenuineIntel
Session Key : 1a6fb761-06c5-4afa-9961-e6d8bf9d25a4
Window System : Version 10.0 (Build 22631)
Fault Count: 1
Abnormal termination:
Unknown exception 0xe0434352
Current Thread: ‘MCR 0 interpreter thread’ id 21248
Register State (from fault):
RAX = 00007ffdccca63e8 RBX = 000000a3a84f3d60
RCX = 000000a3a84f29d0 RDX = 000000a3a84f3530
RSP = 000000a3a84f2150 RBP = 000000a3a84f2830
RSI = 000000a3a84f4b60 RDI = 000000a3a84f2fe0
R8 = 0000000000000081 R9 = 000000a3a84f19f0
R10 = 00007ffde438e866 R11 = 000000a3a84f29d0
R12 = 0000000000000000 R13 = 000000a3a84f22b8
R14 = 0000000000000002 R15 = 000000a3a84f3148
RIP = 00007ffde1a4fabc EFL = 00000206
CS = 0033 FS = 0053 GS = 002b
Stack Trace (from fault):
[ 0] 0x00007ffde1a4fabc C:WINDOWSSystem32KERNELBASE.dll+00391868 RaiseException+00000108
[ 1] 0x00007ffdcdc32743 C:WINDOWSSYSTEM32VCRUNTIME140_1_CLR0400.dll+00010051 _NLG_Return2+00005619
[ 2] 0x00007ffde4414896 C:WINDOWSSYSTEM32ntdll.dll+00673942 RtlCaptureContext2+00001190
[ 3] 0x00007ffdcc4ae012 C:WindowsMicrosoft.NETFramework64v4.0.30319clr.dll+00319506 StrongNameTokenFromPublicKey+00192754
[ 4] 0x00007ffdcc4c5e56 C:WindowsMicrosoft.NETFramework64v4.0.30319clr.dll+00417366 StrongNameTokenFromPublicKey+00290614
[ 5] 0x00007ffdcc49891b C:WindowsMicrosoft.NETFramework64v4.0.30319clr.dll+00231707 StrongNameTokenFromPublicKey+00104955
[ 6] 0x00007ffdcc5ee7b5 C:WindowsMicrosoft.NETFramework64v4.0.30319clr.dll+01632181 DllCanUnloadNowInternal+00011525
[ 7] 0x00007ffd6ce31ce7 <unknown-module>+00000000
[ 8] 0x00007ffdd90f4238 C:Program Files (x86)WoodwardMCSMotoHawk2020b_sp5.2718BlocksMainmotohawk_sfun_check_license.mexw64+00016952 mexFunction+00012856
[ 9] 0x00007ffdd90f422c C:Program Files (x86)WoodwardMCSMotoHawk2020b_sp5.2718BlocksMainmotohawk_sfun_check_license.mexw64+00016940 mexFunction+00012844
[ 10] 0x0000000000000001 <unknown-module>+00000000
This error was detected while a MEX-file was running. If the MEX-file
is not an official MathWorks function, please examine its source code
for errors. Please consult the External Interfaces Guide for information
on debugging MEX-files. matlab, crash MATLAB Answers — New Questions
How can I view full outputs that exceed the maximum line length in the MATLAB Command Window?
I am doing a large computation using the Symbolic Math Toolbox that is resulting in some enormous equations. When trying to view these results, I get the following message in the MATLAB Command Window:
Output truncated. Text exceeds maximum line length for Command Window display.
Is there a way to view the entire result without truncation?I am doing a large computation using the Symbolic Math Toolbox that is resulting in some enormous equations. When trying to view these results, I get the following message in the MATLAB Command Window:
Output truncated. Text exceeds maximum line length for Command Window display.
Is there a way to view the entire result without truncation? I am doing a large computation using the Symbolic Math Toolbox that is resulting in some enormous equations. When trying to view these results, I get the following message in the MATLAB Command Window:
Output truncated. Text exceeds maximum line length for Command Window display.
Is there a way to view the entire result without truncation? commandwindow, output, truncate MATLAB Answers — New Questions
Error while attempting mesh plot
I was experimenting in the Matlab live script editor and I tried to make a mesh plot of a hilbert spectrum, but instead of the plot I obtained an error:
Warning: Error occurred while executing the listener callback for event POST_REGION defined for class matlab.internal.language.RegionEvaluator:
Error using getByteStreamFromArray
Error during serialization
Error in matlab.internal.editor.figure.SerializedFigureState/serialize
Error in matlab.internal.editor.FigureProxy/createWebFigureSnapshot
Error in matlab.internal.editor.FigureManager
Error in matlab.internal.editor.FigureManager
Error in matlab.internal.editor.FigureManager.saveSnapshot
Error in matlab.internal.editor.FigureManager.snapshotAllFigures
Here is the problematic code:
mesh(seconds(t),f,hs, ‘EdgeColor’, ‘none’, ‘FaceColor’, ‘interp’)
xlabel(‘Time (s)’)
ylabel(‘Frequency (Hz)’)
zlabel(‘Instantaneous Energy’)
Any idea why I am getting this error?I was experimenting in the Matlab live script editor and I tried to make a mesh plot of a hilbert spectrum, but instead of the plot I obtained an error:
Warning: Error occurred while executing the listener callback for event POST_REGION defined for class matlab.internal.language.RegionEvaluator:
Error using getByteStreamFromArray
Error during serialization
Error in matlab.internal.editor.figure.SerializedFigureState/serialize
Error in matlab.internal.editor.FigureProxy/createWebFigureSnapshot
Error in matlab.internal.editor.FigureManager
Error in matlab.internal.editor.FigureManager
Error in matlab.internal.editor.FigureManager.saveSnapshot
Error in matlab.internal.editor.FigureManager.snapshotAllFigures
Here is the problematic code:
mesh(seconds(t),f,hs, ‘EdgeColor’, ‘none’, ‘FaceColor’, ‘interp’)
xlabel(‘Time (s)’)
ylabel(‘Frequency (Hz)’)
zlabel(‘Instantaneous Energy’)
Any idea why I am getting this error? I was experimenting in the Matlab live script editor and I tried to make a mesh plot of a hilbert spectrum, but instead of the plot I obtained an error:
Warning: Error occurred while executing the listener callback for event POST_REGION defined for class matlab.internal.language.RegionEvaluator:
Error using getByteStreamFromArray
Error during serialization
Error in matlab.internal.editor.figure.SerializedFigureState/serialize
Error in matlab.internal.editor.FigureProxy/createWebFigureSnapshot
Error in matlab.internal.editor.FigureManager
Error in matlab.internal.editor.FigureManager
Error in matlab.internal.editor.FigureManager.saveSnapshot
Error in matlab.internal.editor.FigureManager.snapshotAllFigures
Here is the problematic code:
mesh(seconds(t),f,hs, ‘EdgeColor’, ‘none’, ‘FaceColor’, ‘interp’)
xlabel(‘Time (s)’)
ylabel(‘Frequency (Hz)’)
zlabel(‘Instantaneous Energy’)
Any idea why I am getting this error? mesh, error MATLAB Answers — New Questions
Plotting two surface plots in the same figure using two different colormaps
Hello,
I have been trying to plot two surface plots on top of each other in the same figure – one that is semitransparent, and one that is opaque – using two colormaps to display them. Specifically, I would like surface plot 1 to use the ‘turbo’ colormap, and surface plot 2 to use the ‘gray’ colormap and be semitransparent. So far, I have read through a few people with similar problems but their solutions don’t help me (most are requesting only 1 specific color per each map and not an entire colormap). How can I do this? Thanks. I cannot provide code due to proprietary information, so any example code given, I will gladly fit to my own.Hello,
I have been trying to plot two surface plots on top of each other in the same figure – one that is semitransparent, and one that is opaque – using two colormaps to display them. Specifically, I would like surface plot 1 to use the ‘turbo’ colormap, and surface plot 2 to use the ‘gray’ colormap and be semitransparent. So far, I have read through a few people with similar problems but their solutions don’t help me (most are requesting only 1 specific color per each map and not an entire colormap). How can I do this? Thanks. I cannot provide code due to proprietary information, so any example code given, I will gladly fit to my own. Hello,
I have been trying to plot two surface plots on top of each other in the same figure – one that is semitransparent, and one that is opaque – using two colormaps to display them. Specifically, I would like surface plot 1 to use the ‘turbo’ colormap, and surface plot 2 to use the ‘gray’ colormap and be semitransparent. So far, I have read through a few people with similar problems but their solutions don’t help me (most are requesting only 1 specific color per each map and not an entire colormap). How can I do this? Thanks. I cannot provide code due to proprietary information, so any example code given, I will gladly fit to my own. colormap, surf, two surface plots, two colormaps MATLAB Answers — New Questions
need solution during trainning
Hello all, I am new in this community .I need help to solve the below problem. please help me..
statement : You can add a custom function at the end of your script. For data preprocessing, the function should take the data returned from the datastore as input. It should return the transformed data as output.
function dataout = functionName(datain)
% do something with datain
dataout = …
end
Given script :
letterds = datastore("*_M_*.txt");
data = read(letterds);
data = scale(data);
plot(data.X,data.Y)
axis equal
plot(data.Time,data.Y)
ylabel("Vertical position")
xlabel("Time")
Task ; –
Create a function called scale at the end of the script that performs the following operations:
data.Time = (data.Time – data.Time(1))/1000;
data.X = 1.5*data.X;
Because these commands modify the variable data directly, your function should use data as both the input and output variable.
Note that the third line of the script calls the scale function. Your script won’t run until this function has been created.
Also note that local functions must be at the end of a script. This means you will be editing the script sections out of order in this interaction. The section headings show which section of the script to edit in each task.Hello all, I am new in this community .I need help to solve the below problem. please help me..
statement : You can add a custom function at the end of your script. For data preprocessing, the function should take the data returned from the datastore as input. It should return the transformed data as output.
function dataout = functionName(datain)
% do something with datain
dataout = …
end
Given script :
letterds = datastore("*_M_*.txt");
data = read(letterds);
data = scale(data);
plot(data.X,data.Y)
axis equal
plot(data.Time,data.Y)
ylabel("Vertical position")
xlabel("Time")
Task ; –
Create a function called scale at the end of the script that performs the following operations:
data.Time = (data.Time – data.Time(1))/1000;
data.X = 1.5*data.X;
Because these commands modify the variable data directly, your function should use data as both the input and output variable.
Note that the third line of the script calls the scale function. Your script won’t run until this function has been created.
Also note that local functions must be at the end of a script. This means you will be editing the script sections out of order in this interaction. The section headings show which section of the script to edit in each task. Hello all, I am new in this community .I need help to solve the below problem. please help me..
statement : You can add a custom function at the end of your script. For data preprocessing, the function should take the data returned from the datastore as input. It should return the transformed data as output.
function dataout = functionName(datain)
% do something with datain
dataout = …
end
Given script :
letterds = datastore("*_M_*.txt");
data = read(letterds);
data = scale(data);
plot(data.X,data.Y)
axis equal
plot(data.Time,data.Y)
ylabel("Vertical position")
xlabel("Time")
Task ; –
Create a function called scale at the end of the script that performs the following operations:
data.Time = (data.Time – data.Time(1))/1000;
data.X = 1.5*data.X;
Because these commands modify the variable data directly, your function should use data as both the input and output variable.
Note that the third line of the script calls the scale function. Your script won’t run until this function has been created.
Also note that local functions must be at the end of a script. This means you will be editing the script sections out of order in this interaction. The section headings show which section of the script to edit in each task. data transformation MATLAB Answers — New Questions