简体   繁体   English

在matlab中同时绘制两个不连续的表面

[英]Plotting two disconnnected surfaces simultaneously in matlab

I'm running a for loop which currently animates surf plots using columns 1:k ( for k=1:301 ) of 3 different matrices (representing x, y, and z) of dimension 21 x 602. However, simultaneously I want to surf plot columns for 302:k+301 , so that in essence, I get the animations of two flux tubes at the same time. 我正在运行一个for循环,目前使用第1列:k( for k=1:301 )的3个不同矩阵(代表x,y和z)的尺寸为21 x 602的情况下动画surf图。但是,同时我想要冲浪图列为for 302:k+301 ,所以从本质上讲,我同时得到了两个磁通管的动画。

Currently, I have: 目前,我有:

p = surf(nan(21,602), nan(21,602), nan(21,602));
for k = 1:301
     % Update all of the plot objects at once
     set(p, 'XData', x(:, 1:k), ...
            'YData', y(:, 1:k), ...
            'ZData', z(:, 1:k),'facecolor', Colour, 'edgecolor',EdgeColour,...
    'facelighting','gouraud')
drawnow
end

But obviously, this is only plotting the first animation as it's currently written. 但显然,这只是绘制了当前编写的第一个动画。 How can this be adapted to also plot the other columns required (and therefore the other animation) at the same time? 如何调整以同时绘制所需的其他列(以及其他动画)?

Thanks 谢谢

How about this: 这个怎么样:

p1 = surf([0 0 ;0 0]);
hold all
p2 = surf([0 0 ;0 0]);
for k = 1:301
    % Update all of the plot objects at once
    set(p1, 'XData', x(:,1:k), ...
        'YData', y(:,1:k), ...
        'ZData', z(:,1:k),'facecolor', Colour, 'edgecolor',EdgeColour,...
        'facelighting','gouraud')
    set(p2, 'XData', a(:,1:k), ...
        'YData', b(:,1:k), ...
        'ZData', c(:,1:k),'facecolor', Colour, 'edgecolor',EdgeColour,...
        'facelighting','gouraud')
    drawnow
end
hold off

x,y,z is the data for one helix, and a,b,c is the data for the other helix. x,y,z是一个螺旋的数据, a,b,c是另一个螺旋的数据。 You need to create two different axes ( p1 and p2 ) so surf wan't connect the data altogether 您需要创建两个不同的轴( p1p2 ),因此surf不会完全连接数据

Hope it answers the question :) 希望它能回答这个问题:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM