用matlab画函数图像

f(x)=x^3-2xsinx,0<=x<=4;该如何输入指令呢

第1个回答  2015-03-11
x=0:0.01:4;f=x.^3-2*x.*sin(x);plot(x,f)追问

>> x=0:0.01:4;
>> f(x)=x.^3-2*x.*sin(x);
Subscript indices must either be real positive integers or logicals.

这是为什么呢?要是x=0:0.01:4;f=x.^3-2*x.*sin(x);plot(x,f)这样直接输入就行

追答

f(x)括号中x表示索引,而索引一定要是整数,所以,f(x)=x.^3-2*x.*sin(x);语句会弹出提示,而f=x.^3-2*x.*sin(x)语句不会弹出提示

本回答被提问者采纳
第2个回答  2020-03-27
第3个回答  2020-10-06
相似回答