Error using ==> load Unable to read file C:\MATLAB7\work\path:No such file or directory.我准备解ode方程,代码如下:function dy=dyn_flexible_pd(t,y)global t_step global M_inv C Im_inv Mdataglobal a v q qm vmglobal qd vd adglobal k kp kd i lo
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/27 17:03:45
Error using ==> load Unable to read file C:\MATLAB7\work\path:No such file or directory.我准备解ode方程,代码如下:function dy=dyn_flexible_pd(t,y)global t_step global M_inv C Im_inv Mdataglobal a v q qm vmglobal qd vd adglobal k kp kd i lo
Error using ==> load Unable to read file C:\MATLAB7\work\path:No such file or directory.
我准备解ode方程,代码如下:
function dy=dyn_flexible_pd(t,y)
global t_step
global M_inv C Im_inv Mdata
global a v q qm vm
global qd vd ad
global k kp kd i
load C.mat
load C:\MATLAB7\work\path planning\qd.txt;
load C:\MATLAB7\work\path planning\vd.txt;
load C:\MATLAB7\work\path planning\ad.txt;
dy=zeros(12,1);
q1=y(1); q2=y(2); q3=y(3); % 关节角
qm1=y(4); qm2=y(5); qm3=y(6); % 电机轴转角
v1=y(7); v2=y(8); v3=y(9); %
vm1=y(10); vm2=y(11); vm3=y(12); % 电机轴转角速度
q1_3=[q1;q2;q3];
qm1_3=[qm1;qm2;qm3];
v1_3=[v1;v2;v3];
v1_3=y(7:9);
vm1_3=y(10:12);
% 将Md、C矩阵转换成字符串
M_inv=inv(eval(Mdata));
C=eval(C);
a1_3= M_inv*(-C*v1_3-100*(q1_3-qm1_3));am1_3=Im_inv*(100*(q1_3-qm1_3)-kp*(qm1_3-qd(:,1:3))-kd*(vm1_3-vd(:,1:3)));
dy(1:3)=y(7:9); % dot[q1; q2; q3]
dy(4:6)=y(10:12); % dot[qm1;qm2;qm3]
dy(7:9)=a1_3; % dot[v1; v2; v3]
dy(10:12)=am1_3; % dot[v1; v2; v3]
求解函数如下:
global t_step
global a1_3 am1_3 M_inv Im_inv C Mdata
global a v q y qm vm tau_1 tau_2 tau_3 tau
global qd vd ad
global k kp kd i
load Mdata.matload I_m.mat
M_inv=inv(Mdata);
Im_inv=inv(I_m);
kp=[3000 0 0;0 3000 0;0 0 3000]; %%%%% 比例增益初值kd=[1000 0 0;0 1000 0;0 0 1000]; %%%%% 微分增益初值
q1_3=[-2.58299305 -1.83851587 1.37078334]';
qm1_3=[0 0 0]';
v1_3=[0 0 0]';
vm1_3=[0 0 0]';
a1_3=[-0.00087598 -0.00117030 0.00173356]';
am1_3=zeros(3,1);
tau_1=zeros(1377,1);
tau_2=zeros(1377,1);
tau_3=zeros(1377,1);
y0=[q1_3; qm1_3; v1_3; vm1_3];% 给定初值
% 设置计算时间的初值和终值
t0=0; t_step=0.25; tf=344;
error=[1e-3;1e-3;1e-3;1e-3;1e-3;1e-3;1e-3;1e-3;1e-3;1e-3;1e-3;1e-3];
options=odeset('InitialStep',t_step,'MaxStep',t_step,'RelTol',1e-3,'AbsTol',error); %ode解微分方程属性设置
[t,y]=ode23(@dyn_flexible_pd,[t0:t_step:tf],y0,options);
save y.mat y
Error using ==> load Unable to read file C:\MATLAB7\work\path:No such file or directory.
load C.mat
load C:\MATLAB7\work\path planning\qd.txt;
load C:\MATLAB7\work\path planning\vd.txt;
load C:\MATLAB7\work\path planning\ad.txt;
Error using ==> load Unable to read file C:\MATLAB7\work\path:No such file or directory.我准备解ode方程,代码如下:function dy=dyn_flexible_pd(t,y)global t_step global M_inv C Im_inv Mdataglobal a v q qm vmglobal qd vd adglobal k kp kd i lo
你试一试把那个代码留在C:\Users \.\Documents\MATLAB
希望可以