フィルターのクリア

Saving plot with variables larger than 2 GB

30 ビュー (過去 30 日間)
Yaser Khojah
Yaser Khojah 2019 年 2 月 26 日
コメント済み: Yaser Khojah 2019 年 3 月 1 日
I'm trying to save a huge boxplot figure but it is working. I used matfile and it is not saving yet. Any idea?
for i = 1:length(s)
subplot(4,5,i);
filename = (['MC Case (' num2str(i) ') .mat']);
m = matfile(filename);
Demand = m.Demand;
Supply_M = m.Supply_M;
Case = m.Case;
demand = Demand / 365;
supply_M = Supply_M / 365;
BoxPlotFunction(demand,supply_M,Case)
end
savefig('BoxPlot');
  3 件のコメント
Munish Raj
Munish Raj 2019 年 3 月 1 日
I'm assuming the question is "but it is not working"
Walter Roberson
Walter Roberson 2019 年 3 月 1 日
編集済み: Walter Roberson 2019 年 3 月 1 日
Your matfile is only used for reading in data, not for saving data. The saving is being done only by the savefig()
Using the compact option for savefig can help with speed.

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

採用された回答

Walter Roberson
Walter Roberson 2019 年 3 月 1 日
編集済み: Walter Roberson 2019 年 3 月 1 日
If you get an error message about file being corrupt when you savefig, then:
Before doing the savefig(), go into your Preferences -> General -> MAT-Files and select "MATLAB Version 7.3 or later". Then do the savefig(). You might as well specify the compact option as the last parameter since your use of matfile tells us that you do not need big backwards compatibility. The figure saving that is done internally will use the -v7.3 format instead of the -v7 format.
  1 件のコメント
Yaser Khojah
Yaser Khojah 2019 年 3 月 1 日
Dear Walter thank you so much for your help. This helps a lot and been looking for answer for awhile. Trule thanks :)

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

その他の回答 (1 件)

Munish Raj
Munish Raj 2019 年 3 月 1 日
Hello Yaser,
The mat file has to be loaded onto the workspace to perform operations on it.
This can be done by using the load command.
load filename
After this is done, you can access those variables the same way you would access any other variable in the workspace.
Your Code will then transalate to
for i = 1:length(s)
subplot(4,5,i);
filename = (['MC Case (' num2str(i) ') .mat']);
load filename
demand = Demand / 365;
supply_M = Supply_M / 365;
BoxPlotFunction(demand,supply_M,Case)
end
savefig('BoxPlot');
  2 件のコメント
Walter Roberson
Walter Roberson 2019 年 3 月 1 日
I doubt this is the issue.
savefig() uses save() internally. If your preferences are set to use -v7 then MATLAB will try to use -v7 when it does the save(), which will fail if any object to be saved is more than 2 gigabytes. If your preferences are set to use -v7.3 then MATLAB will use that for the save() .
Yaser Khojah
Yaser Khojah 2019 年 3 月 1 日
Thanks Munish Raj for your help. I was looking for away to store my data as Walter did. Thank you so much both for taking the time to write these answers.

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

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT-Files についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by