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일

0 개 추천

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일

0 개 추천

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일
it is giving the same error:
Error using print (line 83)
PNG library failed: Write Error.
Error in saveas (line 181)
print( h, name, ['-d' dev{i}] )
Walter Roberson
Walter Roberson 2021년 10월 7일
편집: Walter Roberson 2021년 10월 7일
How large is your axes (how many pixels) ?
Do you have write access to the array 16QAM ?
john karli
john karli 2021년 10월 7일
편집: john karli 2021년 10월 7일
its .mat file contain 1x1024x2 complex variable. the code have save 3385 pngs but after that it gives error of PNG library
There is a chance that file descriptors are leaking. You could periodically
fclose('all')
but that will not help if the file descriptor is leaked inside the png library.
Which operating system are you using? If it is MacOS or Linux I might be able to suggest some tools to check file usage. Windows would take me more research.
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;

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Printing and Saving에 대해 자세히 알아보기

질문:

2021년 10월 7일

댓글:

2021년 10월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by