COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

Input argument is undefined

• Email
• Follow

```I executed the given code in matlab, following error msg shown when i run mds.m file. please help me.

??? Input argument "p" is undefined.

Error in ==> mds at 14
pdot=zeros(size(p));
%PID Controller Simulation Step Function m-File

Kp=10;
Kd=8;
num=[0 Kd Kp];
den=[2 2+Kd 2+Kp];

t=0:0.01:6;
step(num, den,t)
u=num/den;

%MDS Simulation in Z Direction
%Function m-File:
function pdot=mds(t,p)
%Spring Example Problem
m=2; g=-9.81; Kp=10; Kd=8;
%global u tautheta tauphi taupsi
%Parameters-damping coefficient and natural frequency
%forcing function

u=1;
tautheta=1;
tauphi=1;
taupsi=1
pdot=zeros(size(p));
pdot(1)=p(4);
pdot(2)=p(5);
pdot(3)=p(6);
pdot(4)=-u/m*sin(p(7));
pdot(5)=u/m*cos(p(7))*sin(p(8))
pdot(6)=u/m*cos(p(7))*cos(p(8))-g
pdot(7)=p(10);
pdot(8)=p(11);
pdot(9)=p(12);
pdot(10)=tautheta;
pdot(11)=tauphi;
pdot(12)=taupsi;

%ODE Solver m- File:
clear; close all; clc;

dt=0.01; 64

tspan=[0:dt:10];
global u;
% t=1:.1:10;

p0=[0;0;0;0;0;5;0;0;0;0;0;0];

[t,p]=ode45('mds', tspan, p0);

xdot=p(:,2);
x=p(:,1);

figure
subplot(2,1,1)
plot(t,x);
xlabel('time(s)'); ylabel('displ(m)');
subplot(2,1,2)
plot(t,xdot);
```
 0

See related articles to this posting

```"Muhammad " <m07_416@yahoo.com> wrote in message <i72ula\$2id\$1@fred.mathworks.com>...
> I executed the given code in matlab, following error msg shown when i run mds.m file. please help me.
>
> ??? Input argument "p" is undefined.
>
> Error in ==> mds at 14
> pdot=zeros(size(p));
> %PID Controller Simulation Step Function m-File
>
> Kp=10;
> Kd=8;
> num=[0 Kd Kp];
> den=[2 2+Kd 2+Kp];
>
> t=0:0.01:6;
> step(num, den,t)
> u=num/den;
>
> %MDS Simulation in Z Direction
> %Function m-File:
> function pdot=mds(t,p)
> %Spring Example Problem
> m=2; g=-9.81; Kp=10; Kd=8;
> %global u tautheta tauphi taupsi
> %Parameters-damping coefficient and natural frequency
> %forcing function
>
> u=1;
> tautheta=1;
> tauphi=1;
> taupsi=1
> pdot=zeros(size(p));
> pdot(1)=p(4);
> pdot(2)=p(5);
> pdot(3)=p(6);
> pdot(4)=-u/m*sin(p(7));
> pdot(5)=u/m*cos(p(7))*sin(p(8))
> pdot(6)=u/m*cos(p(7))*cos(p(8))-g
> pdot(7)=p(10);
> pdot(8)=p(11);
> pdot(9)=p(12);
> pdot(10)=tautheta;
> pdot(11)=tauphi;
> pdot(12)=taupsi;
>
> %ODE Solver m- File:
> clear; close all; clc;
>
> dt=0.01; 64
>
> tspan=[0:dt:10];
> global u;
> % t=1:.1:10;
>
> p0=[0;0;0;0;0;5;0;0;0;0;0;0];
>
> [t,p]=ode45('mds', tspan, p0);
>
> xdot=p(:,2);
> x=p(:,1);
>
> figure
> subplot(2,1,1)
> plot(t,x);
> xlabel('time(s)'); ylabel('displ(m)');
> subplot(2,1,2)
> plot(t,xdot);

Hi Muhammad, I do not have any problem running this code. Make sure that mds.m is on MATLAB's path (but that does not explain the error message you are reporting). Are you sure that you are running the code exactly as you have posted it? By the way, I think you should put semicolons after a number of lines in mds.m, you are spitting out a lot of output to the command window.

Wayne
```
 0

```hi!
mds.m functions file is on path and out put is also shown when i run step function m file(pdi.m) and ODE Solver m- File(ode.m) , but error msg is shown when i open MDS Simulation in Z Direction Function m-File(mds.m).

Thanx for suggesting me to put semicolons. i just missed those in typing. i have checked remaining code is same that i am running on matlab.
```
 0

```On 18/09/10 12:59 PM, Muhammad wrote:
> I executed the given code in matlab, following error msg shown when i
>
> ??? Input argument "p" is undefined.
>
> Error in ==> mds at 14
> pdot=zeros(size(p));

You have not indicated how you run the file. In particular, you have not
indicated which arguments you are passing to it when you run it. Your
description would be consistent with you simply invoking the name of the
file and expecting it to prompt you for inputs or something like that.
```
 0

```i have created a file mds.m of MDS Simulation in Z Direction Function m-File.
its code is given below also as given before,when i open mds.m in matlab editor and click on run then that error msg is shown. i am beginner to matlab and dont know much about it, i want to know why this eror msg is shown for that if you can tell me or suggest me any tutorial for it, that will be great.

function pdot=mds(t,p)
%Spring Example Problem
m=2; g=-9.81; Kp=10; Kd=8;
%global u tautheta tauphi taupsi
%Parameters-damping coefficient and natural frequency
%forcing function

u=1;
tautheta=1;
tauphi=1;
taupsi=1
pdot=zeros(size(p));
pdot(1)=p(4);
pdot(2)=p(5);
pdot(3)=p(6);
pdot(4)=-u/m*sin(p(7));
pdot(5)=u/m*cos(p(7))*sin(p(8));
pdot(6)=u/m*cos(p(7))*cos(p(8))-g;
pdot(7)=p(10);
pdot(8)=p(11);
pdot(9)=p(12);
pdot(10)=tautheta;
pdot(11)=tauphi;
pdot(12)=taupsi;

```
 0

```On 19/09/10 2:02 PM, Muhammad wrote:
> i have created a file mds.m of MDS Simulation in Z Direction Function
> m-File.
> its code is given below also as given before,when i open mds.m in matlab
> editor and click on run then that error msg is shown. i am beginner to
> matlab and dont know much about it, i want to know why this eror msg is
> shown for that if you can tell me or suggest me any tutorial for it,
> that will be great.

Do not start the function that way. Go to the command line and type in
the name of the function and then an open parenthesis and then all of
the arguments needed by the function (separated by commas) and then a
close parenthesis; press return on the command line when you have
finished entering the command in order to request that it be executed.

The code you show requires two parameters, but does not make use of the
first one so you can pass in any valid expression for the first one. The
second expression must be any array or vector with at least 12 numeric
values.

For example,

mds([], [-.3, .8, pi/7, sqrt(2), rand(1,5), -19.62, log(42), 2])

I have no idea what "good" parameters to pass in would be: the above
just illustrate how to pass in the parameters.
```
 0

5 Replies
1171 Views

Similar Articles

12/6/2013 3:42:05 AM
page loaded in 43038 ms. (0)