I am trying to publish my matlab script, and a figure from a preceding section keeps appearing in the current section. Why is this happening?

7 views (last 30 days)
When I publish this script, figure(4) (K=4.2981) shows up in both the Problem 2 and Problem 3 section when it should only appear in Problem 2:
Capture.JPG
%% ENME462
%% Problem 2
clear all
% Part A
figure(3)
sys = tf([1],[1 4 5 0]);
rlocus(tf([1],[1 4 5 0]))
sgrid(0.5, 100)
hold on
% Part B
[k,poles]=rlocfind(sys)
% Using rlocfind k is approximately 4.2981
K=4.2981;
G = tf([K],[1 4 5 0]);
% Part C
hold off
figure(4)
step(feedback(G,1))
hold on
title('K=4.2981')
hold off
%% Problem 3
clear all
% Part B
figure(5)
for z=0:0.01:100
s=roots([1 4 7 4*z]);
x=real(s);
y=imag(s);
plot(x,y,'b.')
hold on
end
title('Root Locus for P(s)')
grid minor
hold off
xlabel('Real Axis')
ylabel('Imaginary Axis')
% Part C
figure(6)
rlocus(tf(4,[1 4 7 0]))
sgrid
hold on
title('Root Locus for P(s)')
% Part D
z = 0.6
sys1 = tf([4 4*z],[1 4 3 0])
figure(7)
step(feedback(sys1,1))
hold on
title('z=0.6')
S1 = stepinfo(feedback(sys1,1));
PO1 = S1.Overshoot
TS1 = S1.SettlingTime
z = 2
sys2 = tf([4 4*z],[1 4 3 0])
hold off
figure(8)
step(feedback(sys2,1))
hold on
title('z=2')
S2 = stepinfo(feedback(sys2,1));
PO2 = S2.Overshoot
TS2 = S2.SettlingTime
z = 4
sys3 = tf([4 4*z],[1 4 3 0])
hold off
figure(9)
step(feedback(sys3,1))
hold on
title('z=4')
S3 = stepinfo(feedback(sys3,1));
PO3 = S3.Overshoot
TS3 = S3.SettlingTime

Answers (1)

Cris LaPierre
Cris LaPierre on 23 Nov 2019
Not sure. When I publish the code you have above in 2018b, figure 4 does not appear in this section at all. Have you installed all updates (look for a red dot in the upper right of MATLAB)? Is there anything different about the code you are running and the code above?

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!