1 view (last 30 days)
Show older comments
Mukti Tomar on 15 Sep 2021
Edited: Walter Roberson on 24 Sep 2021
Accepted Answer: Walter Roberson
Open in MATLAB Online
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]);
0 Comments Show -2 older commentsHide -2 older comments
Show -2 older commentsHide -2 older comments
Sign in to comment.
Sign in to answer this question.
Accepted Answer
Walter Roberson on 15 Sep 2021
https://www.mathworks.com/help/matlab/ref/ode15i.html
[t,y] = ode15i(odefun,tspan,y0,yp0)
That is a minimum of four parameters. You are passing in three parameters.
4 Comments Show 2 older commentsHide 2 older comments
Show 2 older commentsHide 2 older comments
Mukti Tomar on 15 Sep 2021
Direct link to this comment
https://support.mathworks.com/matlabcentral/answers/1453444-my-code-is-giving-the-error-not-enough-input-arguments-how-to-resolve-this-error-matlab2013a#comment_1736144
i am getting the error even if i use ode23s
Mukti Tomar on 15 Sep 2021
Direct link to this comment
https://support.mathworks.com/matlabcentral/answers/1453444-my-code-is-giving-the-error-not-enough-input-arguments-how-to-resolve-this-error-matlab2013a#comment_1736149
Edited: Walter Roberson on 24 Sep 2021
Open in MATLAB Online
clc;clear all;close all;
[t,x] = ode23s(@tsmcr,[0,8],[0.2 2 0 0 0.2 2 0 0]);
figure(1)
subplot(221)
plot(t,x)
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 *
Inner matrix dimensions must agree.
Error in tsmcr (line 30)
w = norm(P*[x(5);x(6)]) + norm(Q*[x(7);x(8)]) + norm(B1*r) + norm(C1*er) + a2*(b1 + b2*norm([x(1);x(2)])+ b3*norm([x(3);x(4)])^2);
Error in odearguments (line 88)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode23s (line 120)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in slidingmodecontrol2dof (line 2)
[t,x] = ode23s(@tsmcr,[0,8],[0.2 2 0 0 0.2 2 0 0]);
Mukti Tomar on 15 Sep 2021
Direct link to this comment
https://support.mathworks.com/matlabcentral/answers/1453444-my-code-is-giving-the-error-not-enough-input-arguments-how-to-resolve-this-error-matlab2013a#comment_1736164
please tell me how to rectify this error?
Walter Roberson on 15 Sep 2021
Direct link to this comment
https://support.mathworks.com/matlabcentral/answers/1453444-my-code-is-giving-the-error-not-enough-input-arguments-how-to-resolve-this-error-matlab2013a#comment_1736879
Open in MATLAB Online
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)
Sign in to answer this question.
See Also
Categories
MATLABMathematics
Find more on Mathematics in Help Center and File Exchange
Tags
- robotics
- slidingmodecontroller
- 2dofmanipulator
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
Contact your local office