my code is giving the error "not enough input arguments". How to re... (2024)

1 view (last 30 days)

Show older comments

Mukti Tomar on 15 Sep 2021

  • Link

    Direct link to this question

    https://support.mathworks.com/matlabcentral/answers/1453444-my-code-is-giving-the-error-not-enough-input-arguments-how-to-resolve-this-error-matlab2013a

  • Link

    Direct link to this question

    https://support.mathworks.com/matlabcentral/answers/1453444-my-code-is-giving-the-error-not-enough-input-arguments-how-to-resolve-this-error-matlab2013a

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];

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

Sign in to comment.

Sign in to answer this question.

Accepted Answer

Walter Roberson on 15 Sep 2021

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/1453444-my-code-is-giving-the-error-not-enough-input-arguments-how-to-resolve-this-error-matlab2013a#answer_787639

  • Link

    Direct link to this answer

    https://support.mathworks.com/matlabcentral/answers/1453444-my-code-is-giving-the-error-not-enough-input-arguments-how-to-resolve-this-error-matlab2013a#answer_787639

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

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

  • Link

    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

  • Link

    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

  • Link

    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

  • Link

    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.


my code is giving the error "not enough input arguments". How to re... (7)

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

my code is giving the error "not enough input arguments". How to re... (2024)
Top Articles
Clear Ballistic 20% Gel Joe Fit Torso & Mold | Pyramyd AIR
Unraveling The Mystery: Does Greg Gutfeld Have Cancer?
Chs.mywork
Dte Outage Map Woodhaven
Inducement Small Bribe
Pnct Terminal Camera
Ross Dress For Less Hiring Near Me
South Carolina defeats Caitlin Clark and Iowa to win national championship and complete perfect season
Deshret's Spirit
Which aspects are important in sales |#1 Prospection
My.doculivery.com/Crowncork
State Of Illinois Comptroller Salary Database
Edible Arrangements Keller
Los Angeles Craigs List
Craigslist Malone New York
How To Cut Eelgrass Grounded
Zalog Forum
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
‘The Boogeyman’ Review: A Minor But Effectively Nerve-Jangling Stephen King Adaptation
Seeking Arrangements Boston
Wisconsin Volleyball Team Boobs Uncensored
How to Watch Every NFL Football Game on a Streaming Service
Powerschool Mcvsd
Mikayla Campinos: Unveiling The Truth Behind The Leaked Content
Times Narcos Lied To You About What Really Happened - Grunge
Ups Drop Off Newton Ks
134 Paige St. Owego Ny
Life Insurance Policies | New York Life
Nicole Wallace Mother Of Pearl Necklace
Song That Goes Yeah Yeah Yeah Yeah Sounds Like Mgmt
Morlan Chevrolet Sikeston
Iban's staff
Devin Mansen Obituary
Western Gold Gateway
8 Ball Pool Unblocked Cool Math Games
Craigslist Pa Altoona
Craigslist Com Panama City Fl
Ucsc Sip 2023 College Confidential
Hanco*ck County Ms Busted Newspaper
Gabrielle Abbate Obituary
Chubbs Canton Il
The Sports Academy - 101 Glenwest Drive, Glen Carbon, Illinois 62034 - Guide
2000 Ford F-150 for sale - Scottsdale, AZ - craigslist
Is TinyZone TV Safe?
Black Adam Showtimes Near Kerasotes Showplace 14
The Goshen News Obituary
Mkvcinemas Movies Free Download
Edict Of Force Poe
Costco Tire Promo Code Michelin 2022
Unity Webgl Extreme Race
Latest Posts
Article information

Author: Dan Stracke

Last Updated:

Views: 5962

Rating: 4.2 / 5 (63 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Dan Stracke

Birthday: 1992-08-25

Address: 2253 Brown Springs, East Alla, OH 38634-0309

Phone: +398735162064

Job: Investor Government Associate

Hobby: Shopping, LARPing, Scrapbooking, Surfing, Slacklining, Dance, Glassblowing

Introduction: My name is Dan Stracke, I am a homely, gleaming, glamorous, inquisitive, homely, gorgeous, light person who loves writing and wants to share my knowledge and understanding with you.