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

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/07 00:26:19
f=fun(x); f=100*(x(2)-x(1)^2)^2+(1-x(1))^2; x=[1 2]; plot f; 在MATLAB中运行为什么会是错误?

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

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;%主程序
不过我不知道,你想要的是啥,这错的有点,.呵呵,
把你的想法再详细下,发给我再帮你解答,