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

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)

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 Simulink in Help Center and File Exchange

Tags

Asked:

on 24 Jun 2015

Edited:

on 24 Jun 2015

Community Treasure Hunt

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

Start Hunting!