フィルターのクリア

Error in saving plot as PNG?

30 ビュー (過去 30 日間)
john karli
john karli 2021 年 10 月 7 日
コメント済み: Walter Roberson 2021 年 10 月 8 日
for i = 3386:5100
%mkdir 8PSK
x = load(['frame_snr016QAM' num2str(i) '.mat']);
sps = 8;
eyediagram( x.frame , sps)
set(get(gcf, 'Children'), 'Visible', 'off')
cd 16QAM
pause(0.5)
saveas(gcf,['frame_snr016QAM' num2str(i) '.png']);
cd ..
close
end
error
Error using print (line 83)
PNG library failed: Write Error.
Error in saveas (line 181)
print( h, name, ['-d' dev{i}] )
I want to save the plot of eyediagram in a folder. but it was working correctly now i am facing png library failed issue. Please assist

採用された回答

Image Analyst
Image Analyst 2021 年 10 月 7 日
If you have R2020, try exportgraphics() instead of saveas().
And you can also use isfolder(). Replace
if ~exist(outdir, 'dir'); mkdir(outdir); end
with
if ~isfolder(outdir)
mkdir(outdir);
end
  2 件のコメント
john karli
john karli 2021 年 10 月 8 日
it works but how can i save it ?
Walter Roberson
Walter Roberson 2021 年 10 月 8 日
exportgraphics() saves directly to file -- it is a new routine intended to replace print() and saveas()

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 10 月 7 日
編集済み: Walter Roberson 2021 年 10 月 7 日
outdir = '16QAM';
if ~exist(outdir, 'dir'); mkdir(outdir); end
for i = 3386:5100
in_filename = sprintf('frame_snr016QAM%d.mat', i);
out_filename = fullfile(outdir, sprintf('frame_snr016QAM%d.png', i));
x = load(in_filename);
sps = 8;
eyediagram(x.frame, sps)
set(get(gcf, 'Children'), 'Visible', 'off')
pause(0.5)
saveas(gcf, out_filename);
close
end
  6 件のコメント
john karli
john karli 2021 年 10 月 7 日
I am using windows. the error is same
Walter Roberson
Walter Roberson 2021 年 10 月 7 日
You might be able to use Process Explorer to find out whether your process is accumulating open files;

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

カテゴリ

Help Center および File ExchangePrinting and Saving についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by