How can i make a 3d conical helix plot itself slowly?

13 次查看(过去 30 天)
So i have these following lines of code and now all it does is give me the product of the plot right away. However i want to see it being drawn before my eyes! How can this be done? Using drawnow? And if drawnow how do i implemnt it?

采纳的回答

Geoff Hayes
Geoff Hayes 2014-11-25
Fredrik - you can iterate over each element in x, y, and z and either plot the new points, or just update that which has already been plotted with "a little more" data. So we start off as you have done already with
% close any open figures
close all;
% create the helix data to plot
varv=10;
a = 0.05;
c = 5.0;
t = 0:0.01:varv*2*pi;
x = (a*t/2*pi*c).*sin(t);
y = (a*t/2*pi*c).*cos(t);
z = t/(2*pi*c);
% create a figure
figure(3);
Now, we just create the graphics object that will be used to draw the 3D data, and add labels and a title to the axes.
% create the graphics object
h = plot3(NaN,NaN,NaN);
% label the axes
xlabel('x');
ylabel('y');
zlabel('z');
title('Conical helix');
The call to plot3 with NaN inputs does not plot anything, it just creates the graphics handle whose data we will update. We now set limits on the axes so that when we do draw, the axes limits remain fixed.
% set limits
xlim([min(x) max(x)]);
ylim([min(y) max(y)]);
zlim([min(z) max(z)]);
Now we iterate over each point in our data, and update the graphics handle h with the new data, pausing for 1 millisecond to allow the new data to be drawn on the axes.
% plot the data
for k=1:length(x)
set(h,'XData',x(1:k),'YData',y(1:k),'ZData',z(1:k));
pause(0.001);
end
As you can see in the above code, on each iteration of the for loop we update the XData, YData and ZData with a new point.
Try running the above and see what happens!
  5 个评论
Pasindu Gunamuthu
Pasindu Gunamuthu 2020-6-10
I am trying to see the 3D radiation pattern of a Conical spiral antenna. This shape is not available in the antenna toolbox, any idea how can I achieve this ?
Thanks
Geoff Hayes
Geoff Hayes 2020-6-11
Pasindu - please post your comment as a new question as it is not necessarily related to this question.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Objects 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by