matlab求助!!!! 5

functiont=fengposition(R,th1,L1,L2,L4)t=[L1*cos(th1)+L2*cos(R(1));L1*sin(th1)+L2*sin(... function t =fengposition(R,th1,L1,L2,L4)t = [L1*cos(th1) + L2*cos(R(1));L1*sin(th1) + L2*sin(R(1)) - R(4);... 64 + R(5)*sin(R(3)) - L1*sin(th1) - L4*sin(R(2));... 24 + R(5)*cos(R(3)) - L1*cos(th1) - L4*cos(R(2));... R(1) - R(2) - 112*pi/180];% 解方程L1 = 32;L2 = 100;L4 = 28; th1 = 0:1/36:2*pi; options = optimset('display','off'); for i = 1:length(th1) Res(i,:) = fsolve(@fengposition,[1 1 1 1 5],options,th1(i),L1,L2,L4);end %求解速度方程w1 = 5;for j = 1:length(th1) A = [-L2*sin(Res(j,1)) 0 0 0 0;L2*cos(Res(j,1)) 0 0 1 0;... 0 -L4*cos(Res(j,2)) Res(j,5)*cos(Res(j,3)) 0 sin(Res(j,3));... 0 L4*sin(Res(j,2)) -Res(5)*sin(Res(j,3)) 0 cos(Res(j,3));1 -1 0 0 0]; B = [w1*L1*sin(th1(j));-w1*L1*cos(th1(j));w1*L1*cos(th1(j));-w1*L1*sin(th1(j));0]; w = A\B; w2(j) = w(1); w4(j) = w(2); w5(j) = w(3); v3(j) = w(4); v5(j) = w(5); end %求解加速度方程for j = 1:length(th1) C = [-L2*sin(Res(j,1)) 0 0 0 0;L2*cos(Res(j,1)) 0 0 1 0;... 0 -L4*cos(Res(j,2)) Res(j,5)*cos(Res(j,3)) 0 sin(Res(j,3));... 0 L4*sin(Res(j,2)) -Res(j,5)*sin(Res(j,3)) 0 cos(Res(j,3));... 1 -1 0 0 0]; D = [-w2(j)^2*L2*cos(Res(j,1)) + w1^2*L1*cos(th1(j));... w2(j)^2*L2*sin(Res(j,1)) + w1^2*L1*sin(th1(j));... w4(j)^2*L4*sin(Res(j,2)) + w5(j)^2*(Res(j,5)*cos(Res(j,3)) -... Res(j,5)*sin(Res(j,3))) + w5(j)*v5(j)*cos(Res(j,3)) -... w1^2*L1*sin(th1(j));w4(j)^2*L4*cos(Res(j,2)) - ... w5(j)^2*(Res(j,5)*cos(Res(j,3))+Res(j,5)*sin(Res(j,3))) - ... w5(j)*v5(j)*sin(Res(j,3)) - w1^2*L1*cos(th1(j));0]; a = C\D; a = C\D; a3(j) = a(4);endt = th1/5; %绘图plot(t,Res(:,4))gridxlim([0 1.25])title('针头位移曲线图')xlabel('时间(s)')ylabel('针头位移') plot(t,v3)gridxlim([0 1.25])title('针头速度曲线图')xlabel('时间(s)')ylabel('针头速度') plot(t,a3)gridxlim([0 1.25])title('针头加速度曲线图')xlabel('时间(s)')ylabel('针头加速度') 展开
 我来答
百度网友783f227
2018-05-22 · TA获得超过264个赞
知道小有建树答主
回答量:217
采纳率:95%
帮助的人:91.8万
展开全部

我用你的程序,运行的没有问题啊.

追问
是直接运行的吗= =  
我还是出现
>> fengposition(R, th1, L1, L2, L4)
未定义函数或变量 'R'。
追答
这是两个M文件,一个是函数,另一个是程序,你能明白吗?
我发给你吧
这个是函数
function t =fengposition(R,th1,L1,L2,L4)
t = [L1*cos(th1) + L2*cos(R(1)); L1*sin(th1) + L2*sin(R(1)) - R(4);...
64 + R(5)*sin(R(3)) - L1*sin(th1) - L4*sin(R(2));...
24 + R(5)*cos(R(3)) - L1*cos(th1) - L4*cos(R(2));...
R(1) - R(2) - 112*pi/180];
这个是程序,你用我的,要不你的有问题
clc;
clear;
close all;
% 解方程
L1 = 32;
L2 = 100;
L4 = 28;
th1 = 0:1/36:2*pi;
options = optimset('display','off');
for i = 1:length(th1)
Res(i,:) = fsolve(@fengposition,[1 1 1 1 5],options,th1(i),L1,L2,L4);
end
%求解速度方程
w1 = 5;
for j = 1:length(th1)
A = [-L2*sin(Res(j,1)) 0 0 0 0;L2*cos(Res(j,1)) 0 0 1 0;...
0 -L4*cos(Res(j,2)) Res(j,5)*cos(Res(j,3)) 0 sin(Res(j,3));...
0 L4*sin(Res(j,2)) -Res(5)*sin(Res(j,3)) 0 cos(Res(j,3));1 -1 0 0 0];
B = [w1*L1*sin(th1(j));-w1*L1*cos(th1(j));
w1*L1*cos(th1(j));-w1*L1*sin(th1(j));0];
w = A\B;
w2(j) = w(1);
w4(j) = w(2);
w5(j) = w(3);
v3(j) = w(4);
v5(j) = w(5);
end
%求解加速度方程
for j = 1:length(th1)
C = [-L2*sin(Res(j,1)) 0 0 0 0;L2*cos(Res(j,1)) 0 0 1 0;...
0 -L4*cos(Res(j,2)) Res(j,5)*cos(Res(j,3)) 0 sin(Res(j,3));...
0 L4*sin(Res(j,2)) -Res(j,5)*sin(Res(j,3)) 0 cos(Res(j,3));...
1 -1 0 0 0];
D = [-w2(j)^2*L2*cos(Res(j,1)) + w1^2*L1*cos(th1(j));...
w2(j)^2*L2*sin(Res(j,1)) + w1^2*L1*sin(th1(j));...
w4(j)^2*L4*sin(Res(j,2)) + w5(j)^2*(Res(j,5)*cos(Res(j,3))-Res(j,5)*sin(Res(j,3)))+w5(j)*v5(j)*cos(Res(j,3))-w1^2*L1*sin(th1(j));...
w4(j)^2*L4*cos(Res(j,2)) - w5(j)^2*(Res(j,5)*cos(Res(j,3))+Res(j,5)*sin(Res(j,3)))-w5(j)*v5(j)*sin(Res(j,3))-w1^2*L1*cos(th1(j));...
0];
a = C\D;
a = C\D;
a3(j) = a(4);
end
t = th1/5;
俊永翼F
高粉答主

2020-06-16 · 说的都是干货,快来关注
知道答主
回答量:8.1万
采纳率:3%
帮助的人:3866万
展开全部
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式