i was trying to run this function below and the Error message i am getting is Error: Function definitions are not permitted in this context. function y=emfg(u) |Can anyone help me out

1 view (last 30 days)
function y=emfg(u)
if (u>-180)&&(u<=-120)
y=[-1;0;1];
elseif(u>-120)&&(u<=-60)
y=[0;-1;1];
elseif(u>-60)&&(u<=0)
y=[1;-1;0];
elseif(u>0)&&(u<=60)
y=[1;0;-1];
elseif(u>60)&&(u<=120)
y=[0;1;-1];
elseif(u>120)&&(u<=180)
y=[-1;1;0];
end

Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 24 Jun 2015
Edited: Azzi Abdelmalek on 24 Jun 2015
This is a function, you can't run it by clicking on run. You need to call it like this
u=10 % for example
y=emfg(u)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!