A while loop to display a sequence of motion (like a rocket)
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Image Analyst
2015-12-12
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?
回答(1 个)
Image Analyst
2015-12-12
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Contour Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!