what is the most efficient way to write multiple plots to the local drive?

4 ビュー (過去 30 日間)
Abolfazl Nejatian
Abolfazl Nejatian 2023 年 2 月 5 日
コメント済み: Abolfazl Nejatian 2023 年 2 月 6 日
More than 1.5 million plots must be saved to my local drive before my deep network trained.
What is the best way to write this bunch of plots efficiently?
is there any way to write with graphics (GPU)?
here is my code.
figure('visible','off','position',[0,0,244,244]);
parfor i = 1:numel(data)
line_width = 1;
clf,hold on;axis off;
for j = 1:numLines
plot((data{i,1}(j,:)),'LineWidth',line_width);
end
imFileName = [num2str(i) '.jpeg'];
exportgraphics(gca,imFileName);
end
data is a cell with size of 1000000*1
and each cell size is 10*100
All of them need to be saved not to plotted , but it takes many days!
  2 件のコメント
dpb
dpb 2023 年 2 月 5 日
"More than 1.5 million plots must be saved...."
I fail to understand why the plots would have to be saved and what possible use could be made of that many plots even if did?
What do you really need -- the x,y pairs of data inside the plots, maybe? Even if so, there has to be a much more efficient way to approach the end problem, whatever it is...
Abolfazl Nejatian
Abolfazl Nejatian 2023 年 2 月 6 日
I am analyzing forex data using deep learning methods.
My goal is to build up network training data.
For this purpose, I have focused on one-minute candles.
At first, I started with analysis in the frequency domain, but unfortunately I did not get a good answer.
After that, I decided to use the Gaussian Regression model to smooth the past of the market in a multi-resolution manner.
the features became more separatebale for the network.
Now I want to teach these features to the network in the form of continuous images.
For this, I am using a hybrid GoogleNet - LSTM.

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

回答 (2 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023 年 2 月 5 日
In terms of time efficiency, exportgraphics() is faster than saveas().

Walter Roberson
Walter Roberson 2023 年 2 月 5 日
Some performance tune-ups
parfor i = 1:numel(data)
persistent fig ax lines
line_width = 1;
if isempty(fig)
fig = figure('visible','off','position',[0,0,244,244]);
ax = axes(fig);
end
cla(ax);
plot(ax, data{i}.', 'LineWidth', line_width); %plot each ROW
axis(ax, 'off');
imFileName = i + ".jpeg";
exportgraphics(ax,imFileName);
end
  1 件のコメント
Abolfazl Nejatian
Abolfazl Nejatian 2023 年 2 月 6 日
Dear Walter,
Thank you for your comments.
because of the
parfor
this error arised
Error: Persistent variable declarations are not supported in
parfor-loops. For more information, see Parallel for Loops in
MATLAB, "Global and Persistent Variables".
And after that I took persistance varibale out of the loop
persistent fig ax lines
parfor i = 1:numel(data)
if isempty(fig)
fig = figure('visible','off','position',[0,0,244,244]);
ax = axes(fig);
end
cla(ax);
plot(ax, data{i}.', 'LineWidth', 1); %plot each ROW
axis(ax, 'off');
imFileName = i + ".jpeg";
exportgraphics(ax,imFileName);
end
and the error was
The temporary variable 'fig' must be set before it is used. For more
information, see Parallel for Loops in MATLAB, "Uninitialized
Temporaries".
then i try this situation
persistent fig ax lines
if isempty(fig)
fig = figure('visible','off','position',[0,0,244,244]);
ax = axes(fig);
end
parfor i = 1:numel(data)
cla(ax);
plot(ax, data{i}.', 'LineWidth', 1); %plot each ROW
axis(ax, 'off');
imFileName = i + ".jpeg";
exportgraphics(ax,imFileName);
end
and the error is strange for me
Error using exportgraphics
Matrix dimensions must agree.
and the second question is although we have set the size of the figure to 244*244, this size has changed in the output images. how can handle this problem?
My sincere thanks go out to you for your assistance.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by