A while loop to display a sequence of motion (like a rocket)
1 view (last 30 days)
Show older comments
I'm having some problems with this loop. I would want to display something similar to plot(0,k) one by one as an attempt to simulate a rocket launch.
k = [y(:,2)];
noT=size(k,1);
clf;
clear MV;
for ti=1:noT
hold off;
plot(0,k(ti,:),'k-')
axis('image');
pause(0.1)
axis('off');
MV(ti)=getframe;
end;
where size(k,1) is 200 and k ranges from 0.006400000000000E6 to 8.553552443483490E6
Any ideas?
Regards, Christoffer
1 Comment
Image Analyst
on 12 Dec 2015
I don't understand why you're having just a single x value, zero, as your x array, and not an array that is the same length as k(ti,:). Can you give us any values for y?
Answers (1)
Image Analyst
on 12 Dec 2015
Try this:
y = rand(10, 2); % Sample data.
k = y(:,2);
numberOfT = size(k,1);
clf;
clear('MV');
for ti = 1 : numberOfT
plot(1:ti, k(1:ti), 'k*-', 'LineWidth', 2, 'MarkerSize', 15)
caption = sprintf('k vs. ti, for max ti = %d', ti);
title(caption, 'FontSize', 20);
xlabel('ti', 'FontSize', 20);
ylabel('k', 'FontSize', 20);
grid on;
drawnow;
if ti == 1
% 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 ImageAnalyst', 'NumberTitle', 'Off')
end
pause(0.1)
% MV(ti)=getframe;
end
1 Comment
See Also
Categories
Find more on Contour Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!