Why export_fig won't work if code is run automatically?

1 回表示 (過去 30 日間)
Marian
Marian 2014 年 1 月 10 日
コメント済み: Sean de Wolski 2014 年 1 月 13 日
Hi, I've created a script that will update graphs every hour and save them as .jpgs using export_fig. When I manually run the script, it all goes smoothly, but when I use a c-shell to run MATLAB, the .jpg created is scrunched with no plot (only the title and axis labels are there). My .csh looks like this:
#! /bin/csh
matlab -nodisplay -nodesktop -r "run /home/mmateling/realtime/capebird.m"
So the script runs, with no errors, but there must be something wrong with the way my .csh script runs and the export_fig code. I am by no means a unix or matlab expert, so any help would be greatly appreciated!

採用された回答

Image Analyst
Image Analyst 2014 年 1 月 10 日
I think export_fig grabs pixels from the display memory, though I could be wrong. I never would have tried to run it with the nodisplay option so that nothing is displayed. Is anything at all being saved, like whatever happens to be on your screen at the moment?
  2 件のコメント
Marian
Marian 2014 年 1 月 13 日
Sorry, I should've included my code!
set(gcf, 'Color', 'white'); % white bckgr
saveas(gcf,'birdmet.jpg')
drawnow
export_fig(gcf, ... % figure handle
'birdmet',... % name of output file without extension
'-painters', ... % renderer
'-jpg', ... % file format
'-r100'); % resolution in dpi
I used a multitude of different websites to help me get to this point. And I tried taking out nodisplay and it still doesn't work. When I run my code as is, the .jpg is created exactly as I would expect, and is saved into my directory using export_fig
Marian
Marian 2014 年 1 月 13 日
Ok - I've got it working now! Thank you!

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

その他の回答 (1 件)

Sean de Wolski
Sean de Wolski 2014 年 1 月 10 日
編集済み: Sean de Wolski 2014 年 1 月 10 日
Did you drawnow() before exporting/printing?
  2 件のコメント
Marian
Marian 2014 年 1 月 13 日
This must've been the main problem! I wish I could accept both answers - I used
drawnow update expose
and took out the code nodisplay (as Image Analyst said to do, below), and it is finally working. Thank you!
Sean de Wolski
Sean de Wolski 2014 年 1 月 13 日
Well you could vote for 'em both :)

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

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by