plotting very slow and took a long time for the plot tool to show up

146 ビュー (過去 30 日間)
Melissa Chen
Melissa Chen 2018 年 6 月 21 日
編集済み: wagenaartje 2021 年 5 月 1 日
I am plotting 50 graphs in the same plot with these few lines. The data are already in the workspace.
figure; hold on
for n = 1:50
plot(x, y,'LineWidth',2.0);
hold on
end
The figure window shows up within 5 seconds, but it takes MATLAB 3 minutes to populate the graph window with the graphs. Additionally, when I try to use the plot tools to modify the figure, each icon I click or each action I did takes ~ 10 seconds to act, including some simple action like moving the legend position or click to select a specific graph. My computer practically froze while waiting. Initially I thought plotting 50 is too much, but when I try to plot 10 it took about the same amount of time and memory % which is something I've never saw before.
I have a pretty fast computer - an i7 8th generation with 16 GB RAM. I am running on MATLAB R2017b. Running other high memory usage program doesn't have this issue. I have never had this problem with R2017b on another supposedly slower computer - i3 with 32 GB RAM.
I am more of trying to trouble-shoot if this is the problem of the computer or with MATLAB. Thanks.
  2 件のコメント
Steven Lord
Steven Lord 2018 年 6 月 21 日
What are the sizes of x and y?
Husam Alfergani
Husam Alfergani 2020 年 7 月 26 日
use logical index insteasd of for loop. This means plot all at once.
plot(x, y,'LineWidth',2.0);

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

採用された回答

Swarnava Pramanik
Swarnava Pramanik 2018 年 6 月 22 日
Hi Melissa,
I understand you are having some issues while plotting 50 graphs simultaneously on your system. This might be due to some processes that are running in your system in the background which might be taking up enough RAM causing MATLAB to take longer time to plot figures. One solution is to increase the Java Heap Memory for MATLAB. You can do this by the following steps:
Execute the the following command in MATLAB command window:
preferences
A preference window will show up
In that preference window select the “ General ” tab and then select “ Java Heap Memory ”.
Change the size of the “ Java Heap Memory ” as per your requirement. The default is 384 MB but for your case I would suggest increasing it to around 512 – 600 MB
Thanks,
Swarnava Pramanik
  3 件のコメント
Atom Deng
Atom Deng 2021 年 2 月 19 日
How can I know the Java Heap Memory size I need ?
wagenaartje
wagenaartje 2021 年 5 月 1 日
編集済み: wagenaartje 2021 年 5 月 1 日
This is not a good solution, because it seems the memory will be pre-allocated. If you set it too high, MATLAB will slow down your entire system even whe no figures are there.

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

その他の回答 (2 件)

Praveen Muthusamy
Praveen Muthusamy 2020 年 11 月 16 日
I set it to maximum but it is still extremely slow. Matlab 2019b.
Any other suggestion to try?
Thanks

Melissa Chen
Melissa Chen 2018 年 6 月 22 日
Yes this is the exact cause - plotting is a lot faster after I increase the allowable java heap memory and get rid of a few processes that was eating up the RAM.

カテゴリ

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

タグ

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by