Why Matlab is not displaying all the figures?

Hi everyone,
I am running code for basically 5 figures, but only 3 are showing. The other 2 work fine if I run them individually. Can someone please help? Thanks in advance! :)
%Figure1
x = [0:pi/100:2*pi];
y1 = cos(x);
y2 = sin(x);
plot(x,y1,'-k',x,y2,'--b');
xlabel('x (pi)');
ylabel('y(x)');
title('Plot of y1=cos(x) and y2=sin(x)');
axis([0 6 -1 1]);
legend('y1=cos(x)','y2=sin(x)');
%Figure2
M = peaks(50);
figure;
mesh(M);
surf(M);
title('Peaks #2');
%Figure3
x = [-10:0.5:10];
y = [-10:0.5:10];
[xx,yy] = meshgrid(x,y);
r = sqrt(xx.^2+yy.^2);
zz = [cos(r)/2+sin(r)/2];
surf(xx,yy,zz);
title('Surface #3');
%Figure4
k = 5;
n = 2^k-1;
[x,y,z] = sphere(n);
c = hadamard(2^k);
figure;
surf(x,y,z,c);
colormap([1,1,0;0,1,1]);
axis equal;
title('Surface #4');
%Figure5
t=0:0.5:10;
s=0:0.5:10;
[tt,ss] = meshgrid(s,t);
r=5+sin(10*ss+5*tt);
surf(xx,yy,zz);
xx=[ss,tt];
yy=[ss,tt];
zz=[ss,tt];
xx=r*cos(ss)*sin(tt);
yy=r*sin(ss)*sin(tt);
zz=r*cos(tt);
surf(xx,yy,zz);
xlabel('x');
ylabel('y');
zlabel('z');
title('Miscellaneous Surfaces #5');

4 Comments

I am experiencing similar behaviour in 2021a, however, this time they are all separated by the figure command, but only the final figure is spit out:
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
I was essentially ready to start the "tidying up" process, of labeling everything properly etc...
while i was building this code, each Test was checked in a separate script and plotted as intended, so i do not understand how introducing a 6th successfully plotted figure would change it?
thanks
@louis ferreira, most of the way down your code you have this:
%T14
clear all, clc, close all
When you said "close all" you chose to shut down the first 5 figures. (You could have determined this simply by stepping through your code line by line. Debugging in MATLAB | Doug's MATLAB Video Tutorials)
Why did you do that if you wanted them to remain? If you want them to remain, don't call "close all".
yeah must of pasted it in by accident, and didnt notice when i was going through it because i've been looking at the code for days. Never heard of brainfarts?
Your question seems akin to asking a dead person why they got into a car crash if they wished to live...
To improve your analogy: his question is like asking someone who got into a car crash why he wasn't wearing a seat belt.
You are using an editor with a lot of features, including a linter that automatically analyses your code and highlights issues. clear all only needs to exist once in your entire code-base: as part of a script that essentially restarts Matlab. Using it just to wipe old variables is complete over-kill, which is something mlint is warning you about.
info = checkcode('comment_1615298.m','-struct');
numel(info)
ans = 74
When I paste your code in the Matlab editor, 74 check-engine-lights turn on. You should deal with each of them. In general mlint is correct. In the very rare circumstance that it isn't, you can use %#ok to suppress the warning (or better: right-click the orange line and select 'suppress warning on this line'). That way you can still confirm the rest of your code passes the tests.

Sign in to comment.

 Accepted Answer

They are overwriting each other in the figure window. Use a figure command for each new figure.
For example,
if true
% code
end
%Figure1
x = [0:pi/100:2*pi];
y1 = cos(x);
y2 = sin(x);
figure
plot(x,y1,'-k',x,y2,'--b');
xlabel('x (pi)');
ylabel('y(x)');
title('Plot of y1=cos(x) and y2=sin(x)');
axis([0 6 -1 1]);
legend('y1=cos(x)','y2=sin(x)');
%Figure2
M = peaks(50);
figure;
mesh(M);
surf(M);
title('Peaks #2');
%Figure3
x = [-10:0.5:10];
y = [-10:0.5:10];
[xx,yy] = meshgrid(x,y);
r = sqrt(xx.^2+yy.^2);
zz = [cos(r)/2+sin(r)/2];
figure
surf(xx,yy,zz);
title('Surface #3');
%Figure4
k = 5;
n = 2^k-1;
[x,y,z] = sphere(n);
c = hadamard(2^k);
figure;
surf(x,y,z,c);
colormap([1,1,0;0,1,1]);
axis equal;
title('Surface #4');
%Figure5
t=0:0.5:10;
s=0:0.5:10;
[tt,ss] = meshgrid(s,t);
r=5+sin(10*ss+5*tt);
figure
surf(xx,yy,zz);
xx=[ss,tt];
yy=[ss,tt];
zz=[ss,tt];
xx=r*cos(ss)*sin(tt);
yy=r*sin(ss)*sin(tt);
zz=r*cos(tt);
surf(xx,yy,zz);
xlabel('x');
ylabel('y');
zlabel('z');
title('Miscellaneous Surfaces #5');

3 Comments

Thank you so much!
One new problem is that the title for figure 4 is no longer showing on the figure. How do I solve this new problem?
if true
% code
end
%Figure1
x = [0:pi/100:2*pi];
y1 = cos(x);
y2 = sin(x);
plot(x,y1,'-k',x,y2,'--b');
xlabel('x (pi)');
ylabel('y(x)');
title('Plot of y1=cos(x) and y2=sin(x)');
axis([0 6 -1 1]);
legend('y1=cos(x)','y2=sin(x)');
%Figure2
M = peaks(50);
figure;
mesh(M);
surf(M);
title('Peaks #2');
%Figure3
x = [-10:0.5:10];
y = [-10:0.5:10];
[xx,yy] = meshgrid(x,y);
r = sqrt(xx.^2+yy.^2);
zz = [cos(r)/2+sin(r)/2];
figure;
surf(xx,yy,zz);
title('Surface #3');
%Figure4
k = 5;
n = 2^k-1;
[x,y,z] = sphere(n);
c = hadamard(2^k);
figure;
surf(x,y,z,c);
colormap([1,1,0;0,1,1]);
axis equal;
title('Surface #4');
%Figure5
t=0:0.5:10;
s=0:0.5:10;
[tt,ss] = meshgrid(s,t);
r=5+sin(10*ss+5*tt);
surf(xx,yy,zz);
figure;
xx=[ss,tt];
yy=[ss,tt];
zz=[ss,tt];
xx=r*cos(ss)*sin(tt);
yy=r*sin(ss)*sin(tt);
zz=r*cos(tt);
surf(xx,yy,zz);
xlabel('x');
ylabel('y');
zlabel('z');
title('Miscellaneous Surfaces #5');
Did you overlook my answer below? I corrected that for you. If you want separate figures, just replace the subplot's in my code with calls to figure.
Thanks Image Analyst! I did not see your post at first. But it did solve the issue.

Sign in to comment.

More Answers (1)

Use subplot() instead so they can all go on one screen:
%Figure1
fontSize = 25;
x = [0:pi/100:2*pi];
y1 = cos(x);
y2 = sin(x);
subplot(2, 3, 1);
plot(x,y1,'-k',x,y2,'--b');
xlabel('x (pi)');
ylabel('y(x)');
title('Plot of y1=cos(x) and y2=sin(x)', 'fontSize', fontSize);
axis([0 6 -1 1]);
legend('y1=cos(x)','y2=sin(x)');
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Get rid of tool bar and pulldown menus that are along top of figure.
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by Andrino', 'NumberTitle', 'Off')
%Figure2
M = peaks(50);
subplot(2, 3, 2);
mesh(M);
surf(M);
title('Peaks #2', 'fontSize', fontSize);
%Figure3
x = [-10:0.5:10];
y = [-10:0.5:10];
[xx,yy] = meshgrid(x,y);
r = sqrt(xx.^2+yy.^2);
zz = [cos(r)/2+sin(r)/2];
subplot(2, 3, 3);
surf(xx,yy,zz);
title('Surface #3', 'fontSize', fontSize);
%Figure4
k = 5;
n = 2^k-1;
[x,y,z] = sphere(n);
c = hadamard(2^k);
subplot(2, 3, 4);
surf(x,y,z,c);
title('Surface #4', 'fontSize', fontSize);
colormap([1,1,0;0,1,1]);
axis equal;
%Figure5
t=0:0.5:10;
s=0:0.5:10;
[tt,ss] = meshgrid(s,t);
r=5+sin(10*ss+5*tt);
subplot(2, 3, 5);
surf(xx,yy,zz);
title('Surface #5', 'fontSize', fontSize);
xx=[ss,tt];
yy=[ss,tt];
zz=[ss,tt];
xx=r*cos(ss)*sin(tt);
yy=r*sin(ss)*sin(tt);
zz=r*cos(tt);
subplot(2, 3, 6);
surf(xx,yy,zz);
xlabel('x');
ylabel('y');
zlabel('z');
title('Miscellaneous Surfaces #6', 'fontSize', fontSize);

Community Treasure Hunt

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

Start Hunting!