【问题标题】:matlab: Graph 2d lines on x,y and z axis in a 3d plotmatlab:在 3d 图中在 x、y 和 z 轴上绘制 2d 线
【发布时间】:2017-01-19 21:31:21
【问题描述】:

给定一个复杂的信号,我有 3 个维度:I-实部、Q-虚部、T-时间。 我已经能够使用:

plot3(I,T,Q) 

在 matlab 中绘制信号。我现在想将 Q 虚部线图添加到 z 平面,将 I-实部线图添加到 x,y 平面。如何将附加线添加到图表中?我附上了一张我希望它看起来像的图片:

到目前为止,我所拥有的是:

【问题讨论】:

    标签: matlab plot


    【解决方案1】:

    下面的注释代码:

    % hold on for multiple plots
    figure(1)
    hold on
    
    % Plot 3D Figure
    plot3(I,T,Q) 
    
    % Plot on XY plane - means function in Z = 0
    plot3(I,T,Q.*0)
    
    % Plot on YZ plane - means function in X = 0
    plot(I.*0,T,Q)
    
    hold off
    

    在您的情况下,绘制的平面实际上并不是轴的零点。您可能希望将每个 2D 图中的零向量设置为任何单值向量,您可以通过以下方法使其长度正确:

    % vector of 2s the same size as Q
    A = (Q./Q).*2;
    % or
    A = ones(size(Q)).*2;
    % or 
    A = A.*0 + 2;
    

    例如,为您的图像绘制类似的函数:

    x = linspace(0,20,1000);
    
    hold on
    plot3(sin(x),x,cos(x))
    plot3(sin(x),x,cos(x).*0 - 1)
    plot3(sin(x).*0 + 1,x,cos(x))
    grid on
    hold off
    

    【讨论】:

    • 为什么需要 -1 和 +1?
    • @EliMiller 正如我试图在我的回答中间解释的那样,他们将把图转移到平面z=-1x=+1。如果它们为零,则所有图都将相交。自己试试吧!所以纯粹是一种审美的东西......
    • 有没有办法让时间 T 而不是 0-20 从 20 变为 0?
    • 我能够使 YZ 平面等于所有 -1 以将折线图移动到从然后我旋转图。
    • @EliMiller 绘图后:set(gca,'YDir','Reverse')
    猜你喜欢
    • 2018-04-22
    • 2016-07-07
    • 2013-07-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-01
    • 1970-01-01
    相关资源
    最近更新 更多