马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
用matlab 跟simlink做一个驱动机构的仿真,仿真是这样的
其中qbfun函数是这样的:
function y=qbfun(u)
%本程序用于驱动机构仿真模块的配套使用
K=u(1);r2=u(2);alpha2=u(3);omega2=u(4);omega3=u(5);theta2=u(6);theta3=u(7);
T=[K*sin(theta3) 1/r2;-Kcos(theta3) 0];
C=[-sin(theta2)-cos(theta2)-K*cos(theta3)];cos(theta2)-sin(theta2)-K*sin(theta3)];
y=inv(T)*C*[alpha2;omega2^2;omega3^2];
仿真运行函数是这样的:
%clear all;
%初值设定----------------------------------------------------------------------
K=3.8;r=2500;r2=0.196/2; T=4/2;r10=-r2*2;
alpha2=0;omega20=r*pi/30;theta20=-pi;theta30=0;
v10=inv([K*sin(theta30) 1/r2; -K*cos(theta30) 0])*[-omega20*sin(theta20);omega20*cos(theta20)];
omega30=v10(1);v10=v10(2);
%仿真模块运行与处理--------------------------------------------------------------
t=sim('qb',[-30/r,30/r]); t=t*1000;
a=simout(:,1);v=simout(:,2);o=simout(:,3)*180/pi;s=simout(:,4)*1000;
flag=find(t>=T);flag=min(flag);lflag=s(flag)
subplot(2,2,1);plot(t,a,'linewidth',2);axis tight;grid on;
xlabel('\fontsize{8}\bft (ms)');ylabel('\fontsize{8}\bfa (m/s^{2})');title('\fontsize{8}\bft-a曲线');
subplot(2,2,2);plot(t,v,'linewidth',2);axis tight;grid on;
xlabel('\fontsize{8}\bft (ms)');ylabel('\fontsize{8}\bfv (m/s)');title('\fontsize{8}\bft-v曲线');
subplot(2,2,3);plot(t,s,'linewidth',2);axis tight;grid on;
xlabel('\fontsize{8}\bft (ms)');ylabel('\fontsize{8}\bfs (mm)');title('\fontsize{8}\bft-s曲线');
subplot(2,2,4);plot(t,o,'linewidth',2);axis tight;grid on;
xlabel('\fontsize{8}\bft (ms)');ylabel('\fontsize{8}\bf\theta (^{0})');title('\fontsize{8}\bft-\theta曲线');
直接运行sim 会出现这样的错误消息:
Unable to determine signal dimensions. There is a loop consisting of 'qb/qbfun' that cannot be resolved because signal dimensions are defined by a cyclic relationship. Specifying the signal dimensions on Inport, Mux, Selector, Demuxes will help resolve signal dimensions in the loop. You can also use the Signal Specifications to define the signal dimensions.
请大虾帮帮忙啊!!谢谢!!! |