chcm
2012-03-11, 01:30
function f=fun1(x)
if x>1
f=x^2+1;
else if x<=0
f=x^3;
else
f=2*x;
end
end
function f=fun2(x)
if x>1
f=x^2+1;
else if x<=1&x>0
f=2*x;
else
f=x^3;
end
end
问哈懂Matalab的同志,为什么
ezplot('fun1',[-2,2])
所画的函数图是最后一个表达式的图,而
ezplot('fun2',[-2,2])所画的图是对的,但有如下警告:
Warning: Function failed to evaluate on array inputs; vectorizing the function may
speed up its evaluation and avoid the need to loop over array elements.
> In ezplot>ezplot1 at 463
In ezplot at 148
if x>1
f=x^2+1;
else if x<=0
f=x^3;
else
f=2*x;
end
end
function f=fun2(x)
if x>1
f=x^2+1;
else if x<=1&x>0
f=2*x;
else
f=x^3;
end
end
问哈懂Matalab的同志,为什么
ezplot('fun1',[-2,2])
所画的函数图是最后一个表达式的图,而
ezplot('fun2',[-2,2])所画的图是对的,但有如下警告:
Warning: Function failed to evaluate on array inputs; vectorizing the function may
speed up its evaluation and avoid the need to loop over array elements.
> In ezplot>ezplot1 at 463
In ezplot at 148