Matlab plots my equation wrong
1 次查看(过去 30 天)
显示 更早的评论
x=-20:0.1:20;
f2=x.^10-1;
plot(x,f2)
I cant understand why it sketches my basic code wrong.
5 个评论
采纳的回答
Stephen23
2019-3-22
编辑:Stephen23
2019-3-22
MATLAB has plotted exactly what you asked for, where the y-range ranges over:
>> x = -20:0.1:20;
>> y = x.^10-1;
>> max(y)
ans = 10239999999999
>> min(y)
ans = -1
Over that range of y-values I would not expect to be able to distinguish between 0 and -1, they will appear exactly the same on your monitor (unless you have a monitor with more than eleven trillion pixels vertically, in which case those two values will appear one pixel different from each other).
You can limit the plot's y-range if you want:
ylim([-1,3])
or reduce the x-domain:
x = -1.1:0.1:1.1;
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!