Error:Unexpected MATLAB expression.

4 次查看(过去 30 天)
Part o f a program I am writing goes as folows:
if(y2(i)>y1(i))
ntra=ceil((y2(i)-y1(i))/h;
htra=(y2(i)-y1(i))/ntra;
y=[y1(i):htra:y2(i)];
x=xtab(i);
ytabtra=eval(f);
The definition of f beeing:
temp=input('veuillez encoder la fonction principale f(x,y):','s');
f= vectorize(temp);
I tested it with the input '3x+y'
When I programed this yesterday, everything worked, but when I tried again today I get:
??? Error: Unexpected MATLAB expression.
Error in ==> principal_1 at 45
ytabtra=eval(f);
Could anybody help me please?

采纳的回答

Image Analyst
Image Analyst 2012-8-1
编辑:Image Analyst 2012-8-1
Well, what if "f"? You never assigned anything to it, so when it gets to eval(f) it doesn't know what f is. What were you intending? Are you sure that your code assigning f actually was run before you hit the eval statement? Set a breakpoint there to check and make sure f has some string value.
  1 个评论
Karel
Karel 2012-8-1
actually, it was a stupid oversight of my part: instead of entering 3*x+y, I entered 3x+y, which the program didn't recognise, Sorry to have botered you.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by