24小时热门版块排行榜    

查看: 671  |  回复: 0

lmk-kobe

新虫 (初入文坛)

[求助] 基于matlab4杆机构运动分析m文件为什么运行不了

% 曲柄摇杆机构运动分析
% (1)-----计算连杆的输出角th3和摇杆的输出角th4
% 设定各杆的长度(单位:毫米)

rs(1)=304.8;        % 设定机架1长度
rs(2)=101.6;        % 设定曲柄2长度
rs(3)=254.0;        % 设定连杆3长度
rs(4)=177.8;        % 设定摇杆4长度
dr=pi/180.0;% 角度与弧度的转换系数
% 设定初始推测的输入
% 机构的初始位置
th(1)=0.0;          % 设定曲柄2初始位置角是0度(与机架1共线)
th(2)=45*dr;        % 连杆3的初始位置角是 45度
th(3)=135*dr;       % 摇杆4的初始位置角是135度
% 摇杆4的初始位置角可以用三角形的正弦定理确定
th(3)=pi-asin(sin(th(2))*rs(3)/rs(4))
dth=5*dr;                               % 循环增量
% 曲柄输入角从0度变化到360度,步长为5度,计算th34
for i=1:72
    [th3,th4]=ntrps(th,rs); % 调用牛顿—辛普森方程求解机构位置解非线性方程函数文件
    % Store results in a matrix-th34,in degrees
    % 在矩阵th34中储存结果,以度为单位;(i,表示第i行所有列的元素;(:,i)表示第i列所有行的元素
    th34(i,=[th(1)/dr th3/dr th4/dr]; % 矩阵[曲柄转角 连杆转角 摇杆转角]
    th(1)=th(1)+dth;                    % 曲柄转角递增
    th(2)=th3;                          % 连杆转角中间计算值
    th(3)=th4;                          % 摇杆转角中间计算值
end
function[th3,th4]=ntrps(th,rs)
th(1)=theta_2
th(2)=theta_3_bar(starting guess)
th(3)=theta_4_bar(starting guess)
rs(1)=r_1;
rs(2)=r_2;
rs(3)=r_3;
rs(4)=r_4;
th2=th(1);
th3bar=th(2);
th4bar=th(3);
epsilon=1.0E-6;
f=[rs(3)*cos(th3bar)-rs(4)*cos(th4bar)+rs(2)*cos(th2)-rs(1);rs(3)*sin(th3bar)-rs(4)*sin(th4bar)+rs(2)*sin(th2)];
while norm(f)>epsilon
    J=[-rs(3)*sin(th3bar),rs(4)*sin(th4bar);rs(3)*cos(th3bar),-rs(4)*cos(th4bar)];
    d=inv(J)*(-1.0*f);
    th3bar=th3bar+d(1);
    th4bar=th4bar+d(2);
    f=[-rs(3)*cos(th3bar),rs(4)*cos(th4bar);rs(3)*sin(th3bar),-rs(4)*sin(th4bar)];
    norm(f);
end;
th3=th3bar;
th4=th4bar;
% 输出1:四杆机构运动周期(0:5:360),时间,角位移,角速度,角加速度数据
disp '   曲柄转角  连杆转角-摇杆转角-连杆角速度-摇杆角速度-连杆加速度-摇杆加速度'
ydcs=[th34(:,1),th34(:,2),th34(:,3),om34(:,2),om34(:,3),a34(:,2),a34(:,3)];
disp (ydcs)
运行结果
ans =

    66

>>
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 lmk-kobe 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 286分人工智能专业请求调剂愿意跨考! +4 lemonzzn 2026-03-17 8/400 2026-03-21 22:49 by lemonzzn
[考研] 354求调剂 +6 Tyoumou 2026-03-18 9/450 2026-03-21 20:47 by lbsjt
[考研] 考研化学学硕调剂,一志愿985 +5 张vvvv 2026-03-15 7/350 2026-03-21 19:23 by ColorlessPI
[考研] 0703化学调剂 +11 妮妮ninicgb 2026-03-15 15/750 2026-03-21 19:15 by ColorlessPI
[考研] 0805 316求调剂 +3 大雪深藏 2026-03-18 3/150 2026-03-21 18:55 by 学员8dgXkO
[考研] 生物学调剂 +3 Surekei 2026-03-21 3/150 2026-03-21 18:31 by 学员8dgXkO
[考研] 336求调剂 +5 rmc8866 2026-03-21 5/250 2026-03-21 17:24 by 学员8dgXkO
[考研] 332求调剂 +3 凤凰院丁真 2026-03-20 3/150 2026-03-21 10:27 by luoyongfeng
[考研] 机械专硕299求调剂至材料 +3 kkcoco25 2026-03-16 4/200 2026-03-21 03:52 by JourneyLucky
[考研] 二本跨考郑大材料306英一数二 +3 z1z2z3879 2026-03-17 3/150 2026-03-21 02:29 by JourneyLucky
[考研] 332求调剂 +4 ydfyh 2026-03-17 4/200 2026-03-21 02:20 by JourneyLucky
[考研] 求调剂 +3 Ma_xt 2026-03-17 3/150 2026-03-21 02:05 by JourneyLucky
[考研] 南京大学化学376求调剂 +3 hisfailed 2026-03-19 6/300 2026-03-20 23:43 by hisfailed
[考研] 329求调剂 +9 想上学吖吖 2026-03-19 9/450 2026-03-20 22:01 by luoyongfeng
[考研] 中南大学化学学硕337求调剂 +3 niko- 2026-03-19 6/300 2026-03-20 21:58 by luoyongfeng
[考研] 一志愿中南化学(0703)总分337求调剂 +8 niko- 2026-03-19 9/450 2026-03-20 21:57 by luoyongfeng
[考研] 085601材料工程专硕求调剂 +10 慕寒mio 2026-03-16 10/500 2026-03-19 15:26 by 丁丁*
[考研] 0854可跨调剂,一作一项核心论文五项专利,省、国级证书40+数一英一287 +8 小李0854 2026-03-16 8/400 2026-03-18 14:35 by 搏击518
[考研] 收复试调剂生 +4 雨后秋荷 2026-03-18 4/200 2026-03-18 14:16 by elevennnne
[考研] 一志愿,福州大学材料专硕339分求调剂 +3 木子momo青争 2026-03-15 3/150 2026-03-17 07:52 by laoshidan
信息提示
请填处理意见