Why does the MATLAB plot show up with no function on it?

figure()
x = linspace(0,1000);
y1 = (sqrt(2)*sqrt(x.^4 + 9)) ./ (2*x.^2);
plot(x,y1)
xlim([1,2])
ylim([0.8,2])

回答 (1 件)

Jon
Jon 2020 年 11 月 10 日
編集済み: Jon 2020 年 11 月 10 日

0 投票

Your plot limits are outside of the range of the data.
Also you don't have enough (or any data points) in the range of x that you are plotting.
If you truly want to plot for x between 1 and 2 try
figure()
x = linspace(1,2); % just range of interest
y1 = (sqrt(2)*sqrt(x.^4 + 9)) ./ (2*x.^2);
plot(x,y1)
xlim([1,2])
ylim([0.8,2])

3 件のコメント

Jon
Jon 2020 年 11 月 10 日
Note that in your original code
x = linspace(0,1000)
Will generate 50 points (default) between 0 and 1000. This means that your first point is at 0 and the next point is at 10.101, so you didn't have any data at all for x between 1 and 2 which is what your plot limits were set to
Liam Reid
Liam Reid 2020 年 11 月 10 日
Thanks Jon I think I just figured it out!
Jon
Jon 2020 年 11 月 11 日
Please accept this answer if it solved your problem

サインインしてコメントする。

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

質問済み:

2020 年 11 月 10 日

コメント済み:

Jon
2020 年 11 月 11 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by