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 个评论

Please apply a poper code formatting as explained in the "Markup help" link.

请先登录,再进行评论。

回答(2 个)

Jan
Jan 2011-11-15

1 个投票

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 2011-11-15

0 个投票

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

类别

帮助中心File Exchange 中查找有关 Programming 的更多信息

提问:

2011-11-15

Community Treasure Hunt

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

Start Hunting!

Translated by