Why won't Matlab plot anything?

When I try to plot anything, nothing comes up. There are no errors, there's just nothing.
>> x=-10:.1:10;
>> y=sin(x);
>> plot(x,y);
No figure window pops up.

2 件のコメント

777
777 2012 年 3 月 29 日
are there no error reports???
Thomas
Thomas 2012 年 3 月 29 日
Should work.. Does
figure()
open up the figure window?

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

 採用された回答

M
M 2012 年 3 月 29 日

9 投票

You may have previous plot open somewhere and Matlab is plotting it on the same figure. Check for open figures, you might find it.
Alternatively, Use "close all" at the beginning and try again.
close all
x=-10:.1:10;
y=sin(x);
plot(x,y);

10 件のコメント

Josh
Josh 2012 年 3 月 29 日
There's still nothing. I haven't gotten a single plot to come out at all. I assume it's something to do with my preferences, as it's newly installed, but I can't find anything.
Sivan Fox
Sivan Fox 2020 年 1 月 21 日
This worked for me though after some 15 minutes getting mad at my computer. Thanks you!
Tolstoy Hardie
Tolstoy Hardie 2020 年 8 月 1 日
Thanks
Stina Ravdna Lorås
Stina Ravdna Lorås 2020 年 9 月 12 日
I have got almost the same problem. A plot window showes op, but theres nothing on it... No errors showing up...
close all
clear all
M=10
x=-pi:0.01:pi;
grid on
plot (x,(sin(x*(M+(1/2))))/(sin(x/2)))
Han Yan
Han Yan 2021 年 2 月 14 日
wow it works for me too! thanks!
Walter Roberson
Walter Roberson 2021 年 2 月 14 日
plot (x,(sin(x*(M+(1/2))))./(sin(x/2)))
^
Tejas Barethiya
Tejas Barethiya 2022 年 1 月 10 日
thanks...;)
LUKA
LUKA 2022 年 11 月 11 日
legend
Yash dev
Yash dev 2023 年 6 月 15 日
my plot function showing that
plot script as a function is not supported what to do??
DGM
DGM 2023 年 6 月 17 日
Rename your script so that it doesn't conflict with the names of existing functions.

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

その他の回答 (4 件)

Josh
Josh 2012 年 3 月 29 日

2 投票

I typed in figure() and now it works perfectly. Thanks for the help.

1 件のコメント

Jing Yin
Jing Yin 2020 年 3 月 28 日
Thank you. It solves my problem too.

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

Mitchell Frisch
Mitchell Frisch 2019 年 4 月 19 日

0 投票

Try adding a line style to your plot function, such as
plot(x, y 'b-')
I've had a similar problem and this fixed it for me

2 件のコメント

atousa yazdani
atousa yazdani 2022 年 4 月 27 日
hasn't helped me!
Walter Roberson
Walter Roberson 2022 年 4 月 27 日
You do not appear to have posted your code, which makes it difficult for us to tell you how to repair it. It is not at all productive for us to list all of the different ways that can possibly lead to a plot not working as expected.

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

Megat
Megat 2023 年 5 月 23 日

0 投票

q=5; s=0.002; b=20; n=0.03;
g=@(f) ((s*sqrt)*(b*h)^(5/3))/(n*(b+2*h)^(2/3))-q;
fplot(g,[0 1]), grid, xlabel('f'), ylabel('g(f)')
why it show nothing

1 件のコメント

DGM
DGM 2023 年 5 月 24 日
You should get an error message that tells you why.
You created g as a function of f, but not only is it invariant on f, it's a function of h, which is undefined.

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

Sanjay
Sanjay 2025 年 2 月 7 日

0 投票

I use ubuntu operating system. For opening Matlab R2024b I run "/home/user/Documents/MatLab/bin/matlab" as matlab is installed in the "Documents/MatLab" folder. Now for opening plots just add "-softwareopengl" to it. So as a whole the code is "/home/sanjay/Documents/MatLab/bin/matlab -softwareopengl"

カテゴリ

タグ

質問済み:

2012 年 3 月 29 日

回答済み:

2025 年 2 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by