f=fun(x); f=100*(x(2)-x(1)^2)^2+(1-x(1))^2; x=[1 2]; plot f; 在MATLAB中运行为什么会是错误?

来源:学生作业学帮网 编辑:学帮网 时间:2024/06/04 03:53:07

f=fun(x); f=100*(x(2)-x(1)^2)^2+(1-x(1))^2; x=[1 2]; plot f; 在MATLAB中运行为什么会是错误?

如果想用函数绘图
建立两个M文件
function f=fun(x); %函数文件
f=100*(x(2)-x(1)^2)^2+(1-x(1))^2;
第二个:
x=[1 2]; plot f;%主程序
不过我不知道,你想要的是啥,这错的有点,.呵呵,
把你的想法再详细下,发给我再帮你解答,