我目前正试图在同一个图上绘制f(x) = r*x*(1-x) (其中r =3)和y=x,方法是:
syms r x;
f = symfun(r*x*(1-x), x)
r = 3
plot(f,x)
plot(x,x)但是我的代码总是导致错误:
Error using plot
A numeric or double convertible argument is expected请有人帮我指出我哪里出了问题。
发布于 2016-03-08 22:30:00
错误非常明显:将一个数值参数传递给plot。你是在给它一个象征性的功能。只管用
r = 3;
x = 0:0.1:10; %// set some x
f = (r.*x.*(1-x)); %// dots make the multiplication element-wise
figure; %// opens figure
hold on %// plots multiple things in one figure
plot(f,x)
plot(x,x,'r') %// produces a red plot

https://stackoverflow.com/questions/35879055
复制相似问题