% I want the figures to be seperate and not tiled. I'm also trying to avoid creating a 2nd loop for the second figure. The result of the code is that Figure 2 returns empty , while all variables are plotted on figure 3 , with no labels.
I also want to save the figures without displaying them on the command line ? Thanks !
h2 = figure(2); h3 = figure(3); for i = 1:length(k) %%%%%%% Generating first plot
y3 = (1./k(i)).* log(cosh( sqrt(g.*k(i)) .* t) ); displacement2(:,i) = y3; hold on h2 = plot(t,displacement2(:,i)); hold off ax2.Title.String = 'Displacemnt2 vs k'; ax2.XLabel.String = 'time,t [s]'; ax2.YLabel.String = 'Displacement with quadratic friction[m]'; %%%%%%%%%%%%Generating 2nd plot
%Velocity and plot
v3 = sqrt(g./k(i)) * tanh( sqrt(g.*k(i)).* t); velocity2(:,i) = v3; hold on h3 = plot(t,velocity2(:,i)); hold off ax3 = axes('Parent',h3); ax3.Title.String = 'velocity2 vs k'; ax3.XLabel.String = 'time,t [s]'; ax3.YLabel.String = 'velocity2 with quadratic friction[m]' end
Best Answer