MATLAB Answers

my code is giving the error "not enough input arguments". How to resolve this error?(matlab2013a)

2 views (last 30 days)
clc;clear all;close all;
[t,x] = ode15s(@tsmcr,[0,8],[0.2 2 0 0 0.2 2 0 0]);
figure(1)
subplot(221)
plot(t,x(:,1))
hold on
plot(t,x(:,5),':r')
legend('q_1','q_r_1')
grid on
xlabel('time(sec)');ylabel('response of q_1');
subplot(222)
hold on
plot(t,x(:,6),':r')
legend('q_2','q_r_2')
grid on
xlabel('time(sec)');ylabel('response of q_2');
r1 = 1;r2 = 0.8;
J1 = 5;J2 = 5;
m1 = 0.5;m2 = 1.5;
g = 9.8;d = 0.01;
a1 = 0.1;a2 = 2;
b1 = 2;b2 = 1;b3 = 2;
U = zeros(length(t),2);
for i = 1:length(t)
a11 = (m1+m2)*r1^2 + m2r2^2 + 2*m2*r1*r2*cos(x(i,2))+J1;
a12 = m2*r2^2 + m2*r1*r2*cos(x(i,2));
a22 = m2*r2^2 + J2;
b12 = m2*r1*r2*sin(x(i,2));
g1 = -((m1+ m2)*r1*cos(x(i,2)) + m2*r2*cos(x(i,1)+x(i,2)));
g2 = (-m2*r2*cos(x(i,1)+x(i,2)));
r = [5;5];
e1 = x(i,1)-x(i,5);
e2 = x(i,2)-x(i,6);
e1d = x(i,3)-x(i,7);
e2d = x(i,4)-x(i,8);
S = [e1^0.6 + e1d;e2^0.6 + e2d];
P = [-4 0;0 -4];Q = [-5 0;0 -5];B1 = eye(2);C1 = eye(2);
if norm(S)>=d
er = diag([0.6*e1^-0.4,0.6*e2^-0.4])*[e1d;e2d];
% er = [-0.6*e1^0.2,-0.6*e2^0.2];
w = norm(P*[x(i,5);x(i,6)]) + norm(Q*[x(i,7);x(i,8)]) + norm(B1*r) + norm(C1*er) + a2*(b1 + b2*norm([x(i,1);x(i,2)])+ b3*norm([x(i,3);x(i,4)])^2);
U(i,:)= -S/(a1*norm(S))*w;
else
er = [-0.6*e1^0.2,-0.6*e2^0.2];
w = norm(P*[x(i,5);x(i,6)]) + norm(Q*[x(i,7);x(i,8)]) + norm(B1*r) + norm(C1*er) + a2*(b1 + b2*norm([x(i,1);x(i,2)])+ b3*norm([x(i,3);x(i,4)])^2);
U(i,:) = -S/(a1*d)*w;
end
%figure(2)
subplot(223)
plot(t,U(:,1))
grid on
xlabel('time(sec)');ylabel('values of u_1');
subplot(224)
plot(t,U(:,2))
xlabel('time(sec)');ylabel('values of u_2');
grid on
end
Error using ode15i (line 89)
Not enough input arguments. See ODE15I.
Error in slidingmodecontrol2dof (line 2)
[t,x] = ode15i(@tsmcr,[0,8],[0.2 2 0 0 0.2 2 0 0]);

Accepted Answer

Walter Roberson
Walter Roberson on 15 Sep 2021
That is a minimum of four parameters. You are passing in three parameters.
  4 Comments
Walter Roberson
Walter Roberson on 15 Sep 2021
er = diag([0.6*e1^-0.4,0.6*e2^-0.4])*[e1d;e2d];
That is a vector length 2, diag makes it 2 x 2 array. Then * operator with 2 x 1 right hand side, gives you a 2 x 1 result.
er = [-0.6*e1^0.2,-0.6*e2^0.2];
In that branch, er becomes a 1 x 2 vector.
The first branch, you have 2 x 2 * er and er is 2 x 1 so that works out to give 2 x 1.
The second branch, you have 2 x 2 * er and er is 1 x 2, and the * fails.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!