Why isn't the plot showing up?

3 ビュー (過去 30 日間)
Kaylene Widdoes
Kaylene Widdoes 2016 年 1 月 25 日
回答済み: Star Strider 2016 年 1 月 25 日
I'm supposed to have two different figures, one with a resolution of 1, one with a resolution of 0.1. Why aren't the figures showing up? Any suggestions will help.
h = 1; x = 1:h:6; y = (sqrt((x.^4)+1))/(2+sin(x)); figure(1) plot(x,y)
h = .01;
x = 1:h:6;
y = (sqrt((x.^4)+1))/(2+sin(x)); % note that when you change the x vector, you need to recompute the y vect
figure(2)
plot(x,y)

採用された回答

Star Strider
Star Strider 2016 年 1 月 25 日
When in doubt, vectorise everything to do element-wise operations (unless you know you want to do matrix operations).
This will plot your graph:
h = .01;
x = 1:h:6;
y = (sqrt((x.^4)+1))./(2+sin(x)); % note that when you change the x vector, you need to recompute the y vect
figure(2)
plot(x,y)
Note the element-wise division (./) in your ‘y’ assignment.

その他の回答 (1 件)

Image Analyst
Image Analyst 2016 年 1 月 25 日
Is this in a loop? Try drawnow
drawnow;
after you called plot().

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by