matlab error message

I am writing a program for calculating equations of motion . i keep getting this error message
??? function[s n]=eqm1ct(o,~)
|
Error: Function definitions are not permitted in this context.
function[s]=eqm1ct
x=0;
if (x == 1)
w = 1;
while w > 0
u = inputdlg('Enter the Initial velocity:');
[o w]=errchck1(u);
end
if (o ~= 5)
w = 1;
while w > 0
a = inputdlg('Enter the Acceleration:');
[o w]=errchck1(a);
end
end
if (o ~= 5)
w = 1;
while w > 0
t = inputdlg('Enter the Time:');
[o w ]=errchck1(t);
end
end
if (o ~= 5)
u = str2double(u{1});
a = str2double(a{1});
t = str2double(t{1});
vf = (u+(a*t));
uiwait(msgbox(['The Final velocity is: ',num2str(vf)]));
s = 'finalvel';
savefilec(s, vf)
end
thats a apart of the function

1 Comment

Jan
Jan on 15 Nov 2011
Please apply a poper code formatting as explained in the "Markup help" link.

Sign in to comment.

Answers (2)

Jan
Jan on 15 Nov 2011

1 vote

Function can be defined in function files and as nested functions insider another function, but not inside a script or in the command window.
Daniel Shub
Daniel Shub on 15 Nov 2011

0 votes

My guess is that you are either trying to define a function at the command prompt or in a script. Functions are only allowed to be defined in an m file, which only has other functions (i.e., no scripts). See:
and

Categories

Find more on Programming in Help Center and File Exchange

Asked:

on 15 Nov 2011

Community Treasure Hunt

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

Start Hunting!