在图中移动曲线

时间:2017-04-18 09:33:44

标签: matlab user-interface figure

enter image description here

正如您所看到的,在第一张图片中,我有两个子图,两个相同,具有相同的曲线位置。但我需要改变其中一个子图的曲线位置/或视角(如果是左图或右图,则现在不重要)。唯一的工作命令是 CameraViewAngle ,但它会改变它们,我不知道为什么,我需要能够分别改变每一个。 enter image description here 正如您在图2中看到的那样,两者的视角都会发生变化。我宁愿只选择曲线位置。

我使用的代码是:

function [pointsQRS, pointsP, pointsT] = VCG (pointsQRS,pointsP,pointsT)


global ax1 ax2 h

figure('Name','Vektorkardiogram','NumberTitle','off','Color',[0.8 0.8 0.8])
ax1=subplot(1,2,1)
set(ax1,'Position',[0.10,0.11,0.3346590909090909,0.815],'CameraPosition',
[50.197132152696216,49.50150052184264,-7.57531754730548],'CameraTarget',
[0.4, 0.7, -0.33],'View',[-184.4219, -8.9326],'CameraViewAngle',
[9.256133109732078])

title('Vektorkardiogram')
hold on
grid on
view(3)

for i=2:size(pointsQRS,1)
if mod(i,2)==0
        QRS=plot3(pointsQRS([i-1:i],1),pointsQRS([i-1:i],2),pointsQRS([i-
1:i],3),'-g','LineWidth',1);
else
    plot3(pointsQRS([i-1:i],1),pointsQRS([i-1:i],2),pointsQRS([i-
1:i],3),'Color',[0 0 0],'LineWidth',1);
    end
end


for i=2:size(pointsT,1)
if mod(i,2)==0
    T=plot3(pointsT([i-1:i],1),pointsT([i-1:i],2),pointsT([i-1:i],3),'-
r','LineWidth',1);
else
    plot3(pointsT([i-1:i],1),pointsT([i-1:i],2),pointsT([i-1:i],3),'Color',
[0 0 0],'LineWidth',1);
end
end

for i=2:size(pointsP,1)
if mod(i,2)==0
     P=plot3(pointsP([i-1:i],1),pointsP([i-1:i],2),pointsP([i-1:i],3),'-
b','LineWidth',1);
else
    plot3(pointsP([i-1:i],1),pointsP([i-1:i],2),pointsP([i-1:i],3),'Color',
[0 0 0],'LineWidth',1);
end
end

xlabel('Vx');ylabel('Vy');zlabel('Vz');

 mArrow3([1.5 2 -1],[-0.5, 2, -1], 'stemWidth', 
0.005,'color','red','facealpha',0.3);
 mArrow3([1.5 2 -1],[1.5, -0.5, -1], 'stemWidth', 
0.005,'color','red','facealpha',0.3);
 mArrow3([1.5 2 -1],[1.5, 2, 1], 'stemWidth', 
0.005,'color','red','facealpha',0.3);

text(-0.5, 2, -1, 'Vx','FontSize',12);  
text(1.5, -0.5, -1, 'Vy','FontSize',12); 
text(1.5, 2, 1, 'Vz','FontSize',12);







ax2=subplot(1,2,2)
set(ax2,'Position',[0.565,0.11,0.33465909090909096,0.815],'CameraPosition',
[-13.197132152696216,-59.50150052184264,10.57531754730548])

title('Vektorkardiogram')
hold on
grid on
h=linkprop([ax1, ax2],
{'CameraPosition','CameraUpVector','XTick','YTick','ZTick'});

for i=2:size(pointsQRS,1)
if mod(i,2)==0
    QRS=plot3(pointsQRS([i-1:i],1),pointsQRS([i-1:i],2),pointsQRS([i-
1:i],3),'-g','LineWidth',1);
else
    plot3(pointsQRS([i-1:i],1),pointsQRS([i-1:i],2),pointsQRS([i-
1:i],3),'Color',[0 0 0],'LineWidth',1);
end
end


for i=2:size(pointsT,1)
if mod(i,2)==0
    T=plot3(pointsT([i-1:i],1),pointsT([i-1:i],2),pointsT([i-1:i],3),'-
r','LineWidth',1);
else
    plot3(pointsT([i-1:i],1),pointsT([i-1:i],2),pointsT([i-1:i],3),'Color',
[0 0 0],'LineWidth',1);
end
end

for i=2:size(pointsP,1)
if mod(i,2)==0
     P=plot3(pointsP([i-1:i],1),pointsP([i-1:i],2),pointsP([i-1:i],3),'-
b','LineWidth',1);
else
    plot3(pointsP([i-1:i],1),pointsP([i-1:i],2),pointsP([i-1:i],3),'Color',
[0 0 0],'LineWidth',1);
end
end



xlabel('Vx');ylabel('Vy');zlabel('Vz');



   mArrow3([1.5 2 -1],[-0.5, 2, -1], 'stemWidth', 
0.005,'color','red','facealpha',0.3);
   mArrow3([1.5 2 -1],[1.5, -0.5, -1], 'stemWidth', 
0.005,'color','red','facealpha',0.3);
   mArrow3([1.5 2 -1],[1.5, 2, 1], 'stemWidth', 
0.005,'color','red','facealpha',0.3);

  text(-0.5, 2, -1, 'Vx','FontSize',12);  
  text(1.5, -0.5, -1, 'Vy','FontSize',12); 
  text(1.5, 2, 1, 'Vz','FontSize',12);


linkaxes([ax1, ax2])

我需要它来改变它,以便使用Google Cardboard实现3D立体视图。 提前感谢您的帮助!

PS:例如,我希望实现如图3 enter image description here中所示的内容 但是在图片三中,3D曲线没有连接,通过连接,我的意思是当我用其中一个移动时,另一个将以相同的方式移动。

enter image description here

1 个答案:

答案 0 :(得分:0)

我设法部分解决了这个问题。

更改CameraViewAngle,修改曲线的大小,因此我决定保持不变。

不是设置角度,而是将CameraPosition的{​​{1}}设置为与ax2不同,但与目标保持相同的距离。

我没有使用ax1,而是使用了addlistener,并实现了一个回调函数,该函数在linkprop CameraPosition时设置ax2 CameraPosition }被修改。

阅读以下参考页:

以下是代码:

ax1