Missing figures in MATLAB script

The following code is written to graph data and provide mean and standard deviation of data sets desired.
Each one works when in an individual script, but when they are all together, only the final plot plots. initially, all plots plotted fine, then the next day it decided not to.
the only difference with today was the addition of the 6th set of data to be plotted and analysed, which is now the only one that plots...
Each plot is separated by its own "figure(N)", which i thought should have prevented this from occuring.
clear all, clc, close all, warning('off', 'all'),
%T9: Attempt at periodic mechanical mirror tilt (screws were able to be
%tilted, both for x and y by roughly 3pi/2 rads, forward and then back)
%Load data CSV
filename9 = 'LF_BS_MECHTILT_T9.csv';
opt9 = detectImportOptions(filename9);
T9t = readtable(filename9, opt9);
firstdataline9 = opt9.DataLines(1);
T9t.LineNo = (1:height(T9t)).' + (firstdataline9 - 1);
T9t = standardizeMissing(T9t, inf, 'Datavariables', {'X1_um_', 'Y1_um_'});
T9 = rmmissing(T9t);
figure(1)
subplot(2,1,1);
plot((T9{:,{'ms'}})*1e-3 , T9{:,{'X1_um_','Y1_um_'}});
legend({'x1(um)', 'y1(um)'}, 'location', "best");
title('Test 9: Attempt at periodic mechanical mirror tilt (Delta t from human error)');
xlabel('Time (seconds)');
ylabel('Distance From Centre (microns)'); grid on; grid minor;
subplot(2,1,2);
plot((T9{:,{'ms'}})*1e-3 , T9{:,{'I1_V_'}});
legend({'Intensity (Volts)'}, 'location', "best");
title('Test 9 (I(V))')
xlabel('Time (seconds)');
ylabel('Intensity (Volts)');grid on, grid minor;
Nend9 = 9590; Mend9 = 17869;
Nend9 = find(T9.LineNo <= Nend9, 1, 'last')
T9.LineNo(Nend9)
Mend9 = find(T9.LineNo <= Mend9, 1, 'last')
T9.LineNo(Mend9)
Nrange9 = 1 : Nend9;
Mrange9 = Nend9+1:Mend9;
T9NCMX = mean(T9{Nrange9, {'X1_um_'}}, 'omitnan')
T9NCMY = mean(T9{Nrange9, {'Y1_um_'}}, 'omitnan')
T9NCSTDX = std(T9{Nrange9, {'X1_um_'}}, 'omitnan')
T9NCSTDY = std(T9{Nrange9, {'Y1_um_'}}, 'omitnan')
T9CMX = mean(T9{Mrange9, {'X1_um_'}}, 'omitnan')
T9CMY = mean(T9{Mrange9, {'Y1_um_'}}, 'omitnan')
T9CSTDX = std(T9{Mrange9, {'X1_um_'}}, 'omitnan')
T9CSTDY = std(T9{Mrange9, {'Y1_um_'}}, 'omitnan')
%{
Qualitatively: we see clear signs of reduced deviation magnitudes and duration in the Corrected data when compared to the uncorrected data.
Quantitatively:
For the uncorrected range, the beams mean position(x,y) = (-164.2um , -253um)
with standard-deviation(x,y)= (385.8um, 338.2um)
For our corrected range, mean-position(x,y)= (-13.3um, -11.2um)
with standard-deviation(x,y)= (85um, 84um)
Taking ratios of C/NC:
CMX/NCMX = 13.3/385.8 = 0.0345 = 3.45%
CMY/NCMY = 11.2/253.1 = 0.044 = 4.4%
CSTDX/NCSTDX = 85/385.8= 0.22 = 22%
CSTDY/NCSTDY= 84/338.2 = 0.248 = ~25%
%}
% T10: 1hour with OptiSlaps (consistency test)
%Correction applied after ~100seconds
filename10 = 'LF_BS_T10.csv';
opt10 = detectImportOptions(filename10);
T10t = readtable(filename10, opt10);
firstdataline10 = opt10.DataLines(1);
T10t.LineNo = (1:height(T10t)).' + (firstdataline10 - 1);
T10t = standardizeMissing(T10t, inf, 'Datavariables', {'X1_um_', 'Y1_um_'});
T10 = rmmissing(T10t);
figure(2)
subplot(2,1,1);
plot((T10{:,{'ms'}})*1e-3 , T10{:,{'X1_um_','Y1_um_'}});
legend({'x1(um)', 'y1(um)'}, 'location', "best");
title('Test 10: Attempt at periodic mechanical mirror tilt (Delta t from human error)');
xlabel('Time (seconds)');
ylabel('Distance From Centre (microns)'); grid on; grid minor;
subplot(2,1,2);
plot((T10{:,{'ms'}})*1e-3 , T10{:,{'I1_V_'}});
legend({'Intensity (Volts)'}, 'location', "best");
title('Test 10 (I(V))')
xlabel('Time (seconds)');
ylabel('Intensity (Volts)');grid on, grid minor;
Nend10 = 7254; Mend10 = 357062;
Nend10 = find(T10.LineNo <= Nend10, 1, 'last');
T10.LineNo(Nend10)
Mend10 = find(T10.LineNo <= Mend10, 1, 'last');
T10.LineNo(Mend10)
Nrange10 = 1 : Nend10;
Mrange10 = Nend10+1:Mend10;
%Stats, finds mean and standard deviation for the corrected and uncorrected
%ranges
T10NCMX = mean(T10{Nrange10, {'X1_um_'}}, 'omitnan')
T10NCMY = mean(T10{Nrange10, {'Y1_um_'}}, 'omitnan')
T10NCSTDX = std(T10{Nrange10, {'X1_um_'}}, 'omitnan')
T10NCSTDY = std(T10{Nrange10, {'Y1_um_'}}, 'omitnan')
T10CMX = mean(T10{Mrange10, {'X1_um_'}}, 'omitnan')
T10CMY = mean(T10{Mrange10, {'Y1_um_'}}, 'omitnan')
T10CSTDX = std(T10{Mrange10, {'X1_um_'}}, 'omitnan')
T10CSTDY = std(T10{Mrange10, {'Y1_um_'}}, 'omitnan')
%Finds mean and std ratio (C/NC) adn gives as percentage
T10RMX= T10CMX/T10NCMX*100
T10RMY= T10CMY/T10NCMY*100
T10RSTDX= T10CSTDX/T10NCSTDX*100
T10RSTDY= T10CSTDY/T10NCSTDY*100
%{
Qualitatively: We do not see much other than a general convergence to 0 of data points after the 74s mark.
Zooming in does show a far less sinusoidal oscilation, on x and y when correction is applied, however, some of the impacts were strong enough to still deviate the beam from centre by a large amount in the time it takes the FSM to react to a change.
%}
%T11: Single Marble Drop
%Load NC CSV
filename11a = 'LF_BS_NC1b_T11.csv';
opt11a = detectImportOptions(filename11a);
T11at = readtable(filename11a, opt11a);
firstdataline11a = opt11a.DataLines(1);
T11at.LineNo = (1:height(T11at)).' + (firstdataline11a - 1);
T11at = standardizeMissing(T11at, inf, 'Datavariables', {'X1_um_', 'Y1_um_'});
T11a = rmmissing(T11at);
%Load C CSV
filename11b = 'LF_BS_C1b_T11.csv';
opt11b = detectImportOptions(filename11b);
T11bt = readtable(filename11b, opt11b);
firstdataline11b = opt11b.DataLines(1);
T11bt.LineNo = (1:height(T11bt)).' + (firstdataline11b - 1);
T11bt = standardizeMissing(T11bt, inf, 'Datavariables', {'X1_um_', 'Y1_um_'});
T11b = rmmissing(T11bt);
figure(3)
subplot(2,1,1);
plot((T11a{:,{'ms'}})*1e-3 , T11a{:,{'X1_um_','Y1_um_'}}); hold on,
plot((T11b{:,{'ms'}})*1e-3 , T11b{:,{'X1_um_','Y1_um_'}}); hold off,
legend({'x1(um)', 'y1(um)'}, 'location', "best");
title('Test 10: Attempt at periodic mechanical mirror tilt (Delta t from human error)');
xlabel('Time (seconds)');
ylabel('Distance From Centre (microns)'); grid on; grid minor;
subplot(2,1,2);
plot((T11a{:,{'ms'}})*1e-3 , T11a{:,{'I1_V_'}}); hold on,
plot((T11b{:,{'ms'}})*1e-3 , T11b{:,{'I1_V_'}}); hold off,
legend({'Intensity (Volts)'}, 'location', "best");
title('Test 11 (I(V))')
xlabel('Time (seconds)');
ylabel('Intensity (Volts)');grid on, grid minor;
%Stats, finds mean and standard deviation for the corrected and uncorrected
%ranges
T11NCMX = mean(T11a{:, {'X1_um_'}}, 'omitnan')
T11NCMY = mean(T11a{:, {'Y1_um_'}}, 'omitnan')
T11NCSTDX = std(T11a{:, {'X1_um_'}}, 'omitnan')
T11NCSTDY = std(T11a{:, {'Y1_um_'}}, 'omitnan')
T11CMX = mean(T11b{:, {'X1_um_'}}, 'omitnan')
T11CMY = mean(T11b{:, {'Y1_um_'}}, 'omitnan')
T11CSTDX = std(T11b{:, {'X1_um_'}}, 'omitnan')
T11CSTDY = std(T11b{:, {'Y1_um_'}}, 'omitnan')
%Finds mean and std ratio (C/NC) adn gives as percentage
T11RMX= T11CMX/T11NCMX*100
T11RMY= T11CMY/T11NCMY*100
T11RSTDX= T11CSTDX/T11NCSTDX*100
T11RSTDY= T11CSTDY/T11NCSTDY*100
% T12: 3mins marble drops, ~90s NC + ~90s C
filename12 = 'LF_BS_T11_Marble.csv';
opt12 = detectImportOptions(filename12);
T12t = readtable(filename12, opt12);
firstdataline12 = opt12.DataLines(1);
T12t.LineNo = (1:height(T12t)).' + (firstdataline12 - 1);
T12t = standardizeMissing(T12t, inf, 'Datavariables', {'X1_um_', 'Y1_um_'});
T12 = rmmissing(T12t);
figure(4)
subplot(2,1,1);
plot((T12{:,{'ms'}})*1e-3 , T12{:,{'X1_um_','Y1_um_'}});
legend({'x1(um)', 'y1(um)'}, 'location', "best");
title('Test 10: Attempt at periodic mechanical mirror tilt (Delta t from human error)');
xlabel('Time (seconds)');
ylabel('Distance From Centre (microns)'); grid on; grid minor;
subplot(2,1,2);
plot((T12{:,{'ms'}})*1e-3 , T12{:,{'I1_V_'}});
legend({'Intensity (Volts)'}, 'location', "best");
title('Test 10 (I(V))')
xlabel('Time (seconds)');
ylabel('Intensity (Volts)');grid on, grid minor;
Nend12 = 9549; Mend12 = 9463;
Nend12 = find(T12.LineNo <= Nend12, 1, 'last');
T12.LineNo(Nend12)
Mend12 = find(T12.LineNo <= Mend12, 1, 'last');
T12.LineNo(Mend12)
Nrange12 = 1 : Nend12;
Mrange12 = Nend12+1:Mend12;
%Stats, finds mean and standard deviation for the corrected and uncorrected
%ranges
T12NCMX = mean(T12{Nrange12, {'X1_um_'}}, 'omitnan')
T12NCMY = mean(T12{Nrange12, {'Y1_um_'}}, 'omitnan')
T12NCSTDX = std(T12{Nrange12, {'X1_um_'}}, 'omitnan')
T12NCSTDY = std(T12{Nrange12, {'Y1_um_'}}, 'omitnan')
T12CMX = mean(T12{ 9463:17867 , {'X1_um_'}}, 'omitnan')
T12CMY = mean(T12{9463:17867, {'Y1_um_'}}, 'omitnan')
T12CSTDX = std(T12{9463:17867, {'X1_um_'}}, 'omitnan')
T12CSTDY = std(T12{9463:17867, {'Y1_um_'}}, 'omitnan')
%Finds mean and std ratio (C/NC) adn gives as percentage
T12RMX= T12CMX/T12NCMX*100
T12RMY= T12CMY/T12NCMY*100
T12RSTDX= T12CSTDX/T12NCSTDX*100
T12RSTDY= T12CSTDY/T12NCSTDY*100
%T13
% T13: 3mins marble drops, ~90s NC + ~90s C
filename13 = 'LF_BS_T12_MASS.csv';
opt13 = detectImportOptions(filename13);
T13t = readtable(filename13, opt13);
firstdataline13 = opt13.DataLines(1);
T13t.LineNo = (1:height(T13t)).' + (firstdataline13 - 1);
T13t = standardizeMissing(T13t, inf, 'Datavariables', {'X1_um_', 'Y1_um_'});
T13 = rmmissing(T13t);
figure(5)
subplot(2,1,1);
plot((T13{:,{'ms'}})*1e-3 , T13{:,{'X1_um_','Y1_um_'}});
legend({'x1(um)', 'y1(um)'}, 'location', "best");
title('Test 10: Attempt at periodic mechanical mirror tilt (Delta t from human error)');
xlabel('Time (seconds)');
ylabel('Distance From Centre (microns)'); grid on; grid minor;
subplot(2,1,2);
plot((T13{:,{'ms'}})*1e-3 , T13{:,{'I1_V_'}});
legend({'Intensity (Volts)'}, 'location', "best");
title('Test 10 (I(V))')
xlabel('Time (seconds)');
ylabel('Intensity (Volts)');grid on, grid minor;
Nend13 = 9616; Mend13= 9617;
Nend13 = find(T13.LineNo <= Nend13, 1, 'last');
T13.LineNo(Nend13)
Mend13 = find(T13.LineNo <= Mend13, 1, 'last');
T13.LineNo(Mend13)
Nrange13 = 1 : Nend13;
Mrange13 = Nend13+1:Mend13;
%Stats, finds mean and standard deviation for the corrected and uncorrected
%ranges
T13NCMX = mean(T13{Nrange13, {'X1_um_'}}, 'omitnan')
T13NCMY = mean(T13{Nrange13, {'Y1_um_'}}, 'omitnan')
T13NCSTDX = std(T13{Nrange13, {'X1_um_'}}, 'omitnan')
T13NCSTDY = std(T13{Nrange13, {'Y1_um_'}}, 'omitnan')
T13CMX = mean(T13{ 9617:17869 , {'X1_um_'}}, 'omitnan')
T13CMY = mean(T13{9617:17869, {'Y1_um_'}}, 'omitnan')
T13CSTDX = std(T13{9617:17869, {'X1_um_'}}, 'omitnan')
T13CSTDY = std(T13{9617:17869, {'Y1_um_'}}, 'omitnan')
%Finds mean and std ratio (C/NC) adn gives as percentage
T13RMX= T13CMX/T13NCMX*100
T13RMY= T13CMY/T13NCMY*100
T13RSTDX= T13CSTDX/T13NCSTDX*100
T13RSTDY= T13CSTDY/T13NCSTDY*100
%T14
clear all, clc, close all
filename14a = 'LF_BS_NC100g.csv';
opt14a = detectImportOptions(filename14a);
T14at = readtable(filename14a, opt14a);
firstdataline14a = opt14a.DataLines(1);
T14at.LineNo = (1:height(T14at)).' + (firstdataline14a - 1);
T14at = standardizeMissing(T14at, inf, 'Datavariables', {'X1_um_', 'Y1_um_'});
T14a = rmmissing(T14at);
%Load C CSV
filename14b = 'LF_BS_C100g.csv';
opt14b = detectImportOptions(filename14b);
T14bt = readtable(filename14b, opt14b);
firstdataline14b = opt14b.DataLines(1);
T14bt.LineNo = (1:height(T14bt)).' + (firstdataline14b - 1);
T14bt = standardizeMissing(T14bt, inf, 'Datavariables', {'X1_um_', 'Y1_um_'});
T14b = rmmissing(T14bt);
figure(6)
subplot(2,1,1);
plot((T14a{:,{'ms'}})*1e-3 , T14a{:,{'X1_um_','Y1_um_'}}); hold on,
plot((T14b{:,{'ms'}})*1e-3 , T14b{:,{'X1_um_','Y1_um_'}}); hold off,
legend({'x1(um)', 'y1(um)'}, 'location', "best");
title('Test 10: Attempt at periodic mechanical mirror tilt (Delta t from human error)');
xlabel('Time (seconds)');
ylabel('Distance From Centre (microns)'); grid on; grid minor;
subplot(2,1,2);
plot((T14a{:,{'ms'}})*1e-3 , T14a{:,{'I1_V_'}}); hold on,
plot((T14b{:,{'ms'}})*1e-3 , T14b{:,{'I1_V_'}}); hold off,
legend({'Intensity (Volts)'}, 'location', "best");
title('Test 11 (I(V))')
xlabel('Time (seconds)');
ylabel('Intensity (Volts)');grid on, grid minor;
%Stats, finds mean and standard deviation for the corrected and uncorrected
%ranges
T14NCMX = mean(T14a{:, {'X1_um_'}}, 'omitnan')
T14NCMY = mean(T14a{:, {'Y1_um_'}}, 'omitnan')
T14NCSTDX = std(T14a{:, {'X1_um_'}}, 'omitnan')
T14NCSTDY = std(T14a{:, {'Y1_um_'}}, 'omitnan')
T14CMX = mean(T14b{:, {'X1_um_'}}, 'omitnan')
T14CMY = mean(T14b{:, {'Y1_um_'}}, 'omitnan')
T14CSTDX = std(T14b{:, {'X1_um_'}}, 'omitnan')
T14CSTDY = std(T14b{:, {'Y1_um_'}}, 'omitnan')
%Finds mean and std ratio (C/NC) adn gives as percentage
T14RMX= T14CMX/T14NCMX*100
T14RMY= T14CMY/T14NCMY*100
T14RSTDX= T14CSTDX/T14NCSTDX*100
T14RSTDY= T14CSTDY/T14NCSTDY*100
any help would be greatly appreciated.
If i have missed out one of the relevant data files then please let me know.
Thank you.

2 Comments

Jan
Jan on 1 Jul 2021
Edited: Jan on 1 Jul 2021
"then the next day it decided not to." - nope. "it" does not decide anything. Matlab does exactly what you instruct it to do.
"the only difference with today was the addition of the 6th" - please meantion, which ones is the 6th. Can I guess this detail?
Compare the current version with the one from your backup yesterday. Then the difference should get clear.
Unable to find or open 'LF_BS_T10.csv'. Check the path and filename or file permissions.

Sign in to comment.

 Accepted Answer

Jan
Jan on 1 Jul 2021
Edited: Jan on 1 Jul 2021
There is this brute clearing line in the middle of your code:
clear all, clc, close all
Of course it clears all variables and closes all figures.
This clearing is not useful. Use functions to keep your workspace clean. The line on top of the code is even worse:
clear all, clc, close all, warning('off', 'all'),
clear all is a waste of time, because it removes all loaded functions from the memory and relaoding them from the slow disk takes a lot of time. But disabling all warnings is a shot in your knee. Don't do this! Warnings are the friend of the programmer.

7 Comments

Thanks! it appears i pasted that in and forgot about it! what an idiot lol
tbh "clear all, clc, close all" is something i never took further than "its good to start your code with that" when learning it xD
I would normally agree, but here, all the warnings tell me is that matlab doesnt like the names of the data columns but will still work with them anyway, originally i had just added the "warning('off', 'all')" as i was tired of seeing something telling me it doesnt like the way i do a thing that works lol.
thanks
To disable a specific warning, get its ID from the lastwarn command:
[~, MsgID] = lastwarn;
Then copy&paste the warning message into:
warning('off', '<paste here>');
Now only this warning is suppressed, while the others still try to save your live.
It appears I am being stupid again, but in a different way:
I have added the following 3tests to the code for analysis, once again only the last one plots the graph, the other 2 do not, unless they are in a separate script of their own. I am sure there is no "clear all, clc, close all" that I have forgotten (although i am wrong a lot)
%T15
filename15 = 'LF_BS_T15_dzlong.csv';
opt15 = detectImportOptions(filename15);
T15t = readtable(filename15, opt15);
firstdataline15 = opt15.DataLines(1);
T15t.LineNo = (1:height(T15t)).' + (firstdataline15 - 1);
T15t = standardizeMissing(T15t, inf, 'Datavariables', {'X1_um_', 'Y1_um_'});
T15 = rmmissing(T15t);
figure(1)
subplot(2,1,1);
plot((T15{:,{'ms'}})*1e-3 , T15{:,{'X1_um_','Y1_um_'}});
legend({'x1(um)', 'y1(um)'}, 'location', "best");
title('Test 9: Attempt at periodic mechanical mirror tilt (Delta t from human error)');
xlabel('Time (seconds)');
ylabel('Distance From Centre (microns)'); grid on; grid minor;
subplot(2,1,2);
plot((T15{:,{'ms'}})*1e-3 , T15{:,{'I1_V_'}});
legend({'Intensity (Volts)'}, 'location', "best");
title('Test 9 (I(V))')
xlabel('Time (seconds)');
ylabel('Intensity (Volts)');grid on, grid minor;
Nend15 = 9590; Mend15 = 17869;
Nend15 = find(T15.LineNo <= Nend15, 1, 'last')
T15.LineNo(Nend15)
Mend15 = find(T15.LineNo <= Mend15, 1, 'last')
T15.LineNo(Mend15)
Nrange15 = 1 : Nend15;
Mrange15 = Nend15+1:Mend15;
T15NCMX = mean(T15{:, {'X1_um_'}}, 'omitnan')
T15NCMY = mean(T15{:, {'Y1_um_'}}, 'omitnan')
T15NCSTDX = std(T15{:, {'X1_um_'}}, 'omitnan')
T15NCSTDY = std(T15{:, {'Y1_um_'}}, 'omitnan')
T15CMX = mean(T15{:, {'X1_um_'}}, 'omitnan')
T15CMY = mean(T15{:, {'Y1_um_'}}, 'omitnan')
T15CSTDX = std(T15{:, {'X1_um_'}}, 'omitnan')
T15CSTDY = std(T15{:, {'Y1_um_'}}, 'omitnan')
%T16
filename16 = 'LF_BS_T15_dzshort.csv';
opt16 = detectImportOptions(filename16);
T16t = readtable(filename16, opt16);
firstdataline16 = opt16.DataLines(1);
T16t.LineNo = (1:height(T16t)).' + (firstdataline16 - 1);
T16t = standardizeMissing(T16t, inf, 'Datavariables', {'X1_um_', 'Y1_um_'});
T16 = rmmissing(T16t);
figure(1)
subplot(2,1,1);
plot((T16{:,{'ms'}})*1e-3 , T16{:,{'X1_um_','Y1_um_'}});
legend({'x1(um)', 'y1(um)'}, 'location', "best");
title('Test 9: Attempt at periodic mechanical mirror tilt (Delta t from human error)');
xlabel('Time (seconds)');
ylabel('Distance From Centre (microns)'); grid on; grid minor;
subplot(2,1,2);
plot((T16{:,{'ms'}})*1e-3 , T16{:,{'I1_V_'}});
legend({'Intensity (Volts)'}, 'location', "best");
title('Test 9 (I(V))')
xlabel('Time (seconds)');
ylabel('Intensity (Volts)');grid on, grid minor;
Nend16 = 9590; Mend16 = 17869;
Nend16 = find(T16.LineNo <= Nend16, 1, 'last')
T16.LineNo(Nend16)
Mend16 = find(T16.LineNo <= Mend16, 1, 'last')
T16.LineNo(Mend16)
Nrange16= 1 : Nend16;
Mrange16= Nend16+1:Mend16;
T16NCMX = mean(T16{:, {'X1_um_'}}, 'omitnan')
T16NCMY = mean(T16{:, {'Y1_um_'}}, 'omitnan')
T16NCSTDX = std(T16{:, {'X1_um_'}}, 'omitnan')
T16NCSTDY = std(T16{:, {'Y1_um_'}}, 'omitnan')
T16CMX = mean(T16{:, {'X1_um_'}}, 'omitnan')
T16CMY = mean(T16{:, {'Y1_um_'}}, 'omitnan')
T16CSTDX = std(T16{:, {'X1_um_'}}, 'omitnan')
T16CSTDY = std(T16{:, {'Y1_um_'}}, 'omitnan')
%T17
filename17 = 'LF_BS_T15_dzshortest.csv';
opt17 = detectImportOptions(filename17);
T17t = readtable(filename17, opt17);
firstdataline17 = opt17.DataLines(1);
T17t.LineNo = (1:height(T17t)).' + (firstdataline17 - 1);
T17t = standardizeMissing(T17t, inf, 'Datavariables', {'X1_um_', 'Y1_um_'});
T17 = rmmissing(T17t);
figure(1)
subplot(2,1,1);
plot((T17{:,{'ms'}})*1e-3 , T17{:,{'X1_um_','Y1_um_'}});
legend({'x1(um)', 'y1(um)'}, 'location', "best");
title('Test 9: Attempt at periodic mechanical mirror tilt (Delta t from human error)');
xlabel('Time (seconds)');
ylabel('Distance From Centre (microns)'); grid on; grid minor;
subplot(2,1,2);
plot((T17{:,{'ms'}})*1e-3 , T17{:,{'I1_V_'}});
legend({'Intensity (Volts)'}, 'location', "best");
title('Test 9 (I(V))')
xlabel('Time (seconds)');
ylabel('Intensity (Volts)');grid on, grid minor;
Nend17 = 9590; Mend17 = 17869;
Nend17 = find(T17.LineNo <= Nend17, 1, 'last')
T17.LineNo(Nend17)
Mend17 = find(T17.LineNo <= Mend17, 1, 'last')
T17.LineNo(Mend17)
Nrange17= 1 : Nend17;
Mrange17= Nend17+1:Mend17;
T17NCMX = mean(T17{:, {'X1_um_'}}, 'omitnan')
T17NCMY = mean(T17{:, {'Y1_um_'}}, 'omitnan')
T17NCSTDX = std(T17{:, {'X1_um_'}}, 'omitnan')
T17NCSTDY = std(T17{:, {'Y1_um_'}}, 'omitnan')
T17CMX = mean(T17{:, {'X1_um_'}}, 'omitnan')
T17CMY = mean(T17{:, {'Y1_um_'}}, 'omitnan')
T17CSTDX = std(T17{:, {'X1_um_'}}, 'omitnan')
T17CSTDY = std(T17{:, {'Y1_um_'}}, 'omitnan')
Your help would once again be much appreciated, thanks
upon re-testing, if i comment out "T7", then T15 doens't plot but T16 does, if i comment out T16 and T17, T15 now plots :S
Jan
Jan on 2 Jul 2021
Edited: Jan on 2 Jul 2021
You plot all output to a single figure: figure(1) . Therefore the contents is overwitten.
I'd prefer to use just figure() to be sure a new figure is opened at each call.
thanks, i wasnt sure how it treats the number in the figure(N) function, many times I have accidentally pasted the same number in there and it's been fine lol
If the figure already exists, the figure(n) will make that figure the current figure. If your next action is plotting to the figure, then the plot command replaces the current plot (if hold is off), or adds to the current axes (if hold is on).
This is a general rule of thumb. Some axes types behave differently, but since you use plot, this is the behavior you can expect with this script.

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Products

Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!