MATLAB: Plotting all iterations on a single graph?

  • Context: MATLAB 
  • Thread starter Thread starter plexus0208
  • Start date Start date
  • Tags Tags
    Graph Matlab Plotting
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 6K views
plexus0208
Messages
49
Reaction score
0
I want to plot r vs. Total_thrust for all iterations on a single graph. I'm using 'hold on;' but it is still only plotting the last iteration. Help?

-------------------MATLAB CODE----------------------------------
Thrust = (mdot19*c19 + mdot9*c9)/gc; %Note: This is for one engine

if(imag(Thrust) == 0 ),
Total_thrust(i) = Thrust*2; %in lbf
SFC(i) = (mdotf/Thrust)*3600; %in (lbm/hr)/lbf
r(i) = radius_inlet;
i = i+1;
end

radius_inlet = radius_inlet + .1;

end

Tt4 = Tt4 + 30;
plot(r,Total_thrust);
hold on;

end
 
Physics news on Phys.org
Unless there's some additional code that's not included here, you seem to have some superfluous end statements. If you go through the hold route, you generally want to make sure that the plot data iterates several times (otherwise, it's useless).

F'r instance:
Code:
%Sine plotter
t=0:0.01:2*pi;
hold on
for n=1:1:5
	plot(t, sin(n*t));
end
hold off;
 
Last edited: