Error in code for legend plot

1 vue (au cours des 30 derniers jours)
Mohsen Nashel
Mohsen Nashel le 8 Oct 2019
I am trying to run this code and its giving me multiple errors! Please help
varInput = load('quadData.mat');
qDat = varInput.quadrotor;
[n,~] = size(qDat);
Xi_0 = [qDat(1,2:4)'; qDat(1,8:10)'];
v = qDat(:,5:7);
omega = qDat(:,11:13);
t=qDat(:,1);
dt=qDat(2,1) - qDat(1,1);
T_initial = qDat(1,1);
T_final = qDat(end,1);
phi=qDat(:,8);
th=qDat(:,9);
psi=qDat(:,10);
q_tr=[cos(0.5*psi).*cos(0.5*th).*cos(0.5*phi)+sin(0.5*psi).*sin(0.5*th).*sin(0.5*phi),cos(0.5*psi).*cos(0.5*th).*sin(0.5*phi)-sin(0.5*psi).*sin(0.5*th).*cos(0.5*phi),cos(0.5*psi).*sin(0.5*th).*cos(0.5*phi)+sin(0.5*psi).*cos(0.5*th).*sin(0.5*phi),sin(0.5*psi).*cos(0.5*th).*cos(0.5*phi)-cos(0.5*psi).*sin(0.5*th).*sin(0.5*phi)]
Xi_0=[qDat(1,2:4)';q_tr(1,:)'];
pose_dot(1,Xi_0,dt,v,omega);
[t_out,Xi] = ode45(@pose_dot,[T_initial T_final],Xi_0);
figure
plot(t_out,Xi(:,4:7),':');
hold on
plot(t,q_tr,'-');
legend('q_0', 'q_q','q_2','q_3','q_{0,true}','q_{1,true}','q_{2,true}','q_{3,true}');
grid on
title('Quanternions vs. Time Graph');
xlabel('Time s');
ylabel('Quanternion');
figure
plot(t_out,Xi(:,1:3),':');
hold on
plot(t,qDat(:,2:4),'-');
legend('x_{calc}','y_{calc}','z_{calc}','x_{true}','y_{true}','z_{true}');
grid on
title('Position vs. Time');
xlabel('Time s');
ylabel('Position m');
function Xi_dot = pose_dot(t,Xi,prstVars)
if nargin>2
dt = prstVars{1};
v = prstVars{2};
omega = prstVars{3};
end
ind = floor(t/dt) + 1;
nu = [v(ind,:)'; 0.5*Xi(4:7)];
q0 = Xi(4);
q1 = Xi(5);
q2 = Xi(6);
q3 = Xi(7);
Xi_dot=[q0^2+q1^2-q2^2-q3^2 2*(q2*q1-q0*q3) 2*(q3*q1+q0*q2) 0 0 0 0;2*(q2*q1+q0*q3) q0^2-q1^2+q2^2-q3^2 2*(q3*q2-q0*q1) 0 0 0 0;2*(q3*q1-q0*q2) 2*(q3*q2-q0*q1) q0^2-q1^2-q2^2+q3^2 0 0 0 0;0 0 0 0 -omega(ind,1) -omega(ind,2) -omega(ind,3);0 0 0 omega(ind,1) 0 omega(ind,3) -omega(ind,2);0 0 0 omega(ind,2) -omega(ind,3) 0 omega(ind,1);0 0 0 omega(ind,3) omega(ind,2) -omega(ind,1) 0]*nu;
end

Réponses (1)

Siriniharika Katukam
Siriniharika Katukam le 11 Oct 2019
Hi
The major error that I observe in your code is "Too many input arguments" to the function "pose_dot".
Make sure you decrease the number of inputs and pass them in the order required.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by