我正试图将我的一个脚本转录到Matlab中的AppDesigner中,以便轻松地分发给学生。其目的是实时显示作用在车辆上6个自由度的力和力矩(基于用户通过操纵杆的输入)。我现在使用的是一个非常简单的动画,由多个3d箭头图组成(每0.1s刷新一次),但它确实做到了。我想得到的是显示在第一个图,而第二个图显示的是我实际得到的应用程序设计器。
我在app designer中用于绘图的相关代码行如下:
function plot_ROV(app)
% Plot the forces and moments acting on the ROV in the correct graph:
quiver3(app.UIAxes,0,0,0,1,0,0);
hold(app.UIAxes);
quiver3(app.UIAxes,0,0,0,0,1,0);
hold(app.UIAxes);
quiver3(app.UIAxes,0,0,0,0,0,1);
hold(app.UIAxes);
quiver3(app.UIAxes,0,0,0,app.Surge,0,0,’LineWidth’,5,’Color’,app.Colors(1,:));
hold(app.UIAxes);
quiver3(app.UIAxes,0,0,0,0,app.Sway,0,’LineWidth’,5,’Color’,app.Colors(2,:));
hold(app.UIAxes);
quiver3(app.UIAxes,0,0,0,0,0,app.Heave,’LineWidth’,5,’Color’,app.Colors(3,:));
hold(app.UIAxes);
app.circular_arrow3([1,0,0],app.Roll,0.2,app.Colors(4,:));
hold(app.UIAxes);
app.circular_arrow3([0,1,0],app.Pitch,0.2,app.Colors(5,:));
hold(app.UIAxes);
app.circular_arrow3([0,0,1],app.Yaw,0.2,app.Colors(6,:));
hold(app.UIAxes);
legend(app.UIAxes,’x-axis’,’y-axis’,’z-axis’,’surge’,’sway’,’heave’,’roll’,’roll’,…
‘pitch’,’pitch’,’yaw’,’yaw’,’Location’,’BestOutside’);
end
function circular_arrow3(app,axis,angle,radius,color)
% Generate the data for the circle in 2D space:
np = 10; % no. points
a = linspace(0,angle*pi,np);
p = [radius.*cos(a);radius.*sin(a);zeros(1,np)];
% Select the correct rotation matrix depending on the axis:
if sum((axis-[1,0,0]).^2)==0
R = [0,0,1;0,1,0;-1,0,0];
elseif sum((axis-[0,1,0]).^2)==0
R = [1,0,0;0,0,-1;0,1,0];
p(2,:) = – p(2,:);
elseif sum((axis-[0,0,1]).^2)==0
R = eye(3);
else
error(‘Only rotations about the x-, y- and z-axes are supported’);
end
% Rotate the points:
pr = zeros(size(p));
for i=1:np
pr(:,i) = R*p(:,i);
end
% Calculate the difference between the last two points:
x = pr(1,end);
y = pr(2,end);
z = pr(3,end);
u = pr(1,end)-pr(1,end-1);
v = pr(2,end)-pr(2,end-1);
w = pr(3,end)-pr(3,end-1);
% Plot the points:
plot3(app.UIAxes,pr(1,:),pr(2,:),pr(3,:),’LineWidth’,4,’Color’,color);
hold(app.UIAxes);
quiver3(app.UIAxes,x,y,z,u,v,w,’LineWidth’,6,’Color’,color);
end
现在,通过比较这两个数字,我想我的问题是
hold
命令不起作用,至少不是我想要的那样:只显示最后一个圆形箭头中的点。由于我对app designer没有太多经验,我的感觉是我一定犯了一个基本的错误。
提前谢谢你的帮助!
相关资源:欧德克连杆仿真设计软件Linkage_linkage软件-其它工具类资源-CSDN…
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!