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 件のコメント
Jan
2011 年 11 月 15 日
Please apply a poper code formatting as explained in the "Markup help" link.
回答 (2 件)
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
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 についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!