Using "print" with no desktop?

조회 수: 4 (최근 30일)
Marian
Marian 2014년 1월 17일
댓글: Marian 2014년 1월 22일
I've got code that runs every hour and updates a graph. Using the print function, it creates a graph and saves it as a .jpg. However, the resolution is very low. When I run the code manually, it creates and saves the .jpg exactly as I want it. But when I am logged out (and the desktop is not available to MATLAB), the image created is poor quality. Here's my code for saving the plot:
print -djpeg birdmet.jpg -r100
drawnow
set(gcf, 'Color', 'white'); % white bckgr
I also have a .csh script to run my code, maybe it's the cause of the problem?:
#! /bin/csh
matlab -nodesktop -r "run /home/mmateling/realtime/capebird.m"
Any help would be greatly appreciated!
  댓글 수: 2
Oliver Woodford
Oliver Woodford 2014년 1월 17일
You haven't provided code that we can just run. However, I created a script called test.m containing
plot(rand(3));
drawnow;
print('test.jpg', '-djpeg');
and called
matlab -nodesktop -r "test"
and it worked fine, producing a sensible looking jpeg. That was on a Windows PC. What does your code run on?
Marian
Marian 2014년 1월 17일
My code runs on Linux. It uses data that it pulls from 48 .dat files and plots them in chronological order with 4 subplots. The quality isn't awful, I would just prefer the image be larger. It creates the resolution I want (-r100) only when I am logged in, so that the desktop is accessible. When I log out (overnight), the .jpg is standard size. I've been searching the web for a way to improve the quality when run without the desktop, but to no avail.The lines I used to graph are as follows:
figure(1)
subplot(4,1,1)
plot(time,Tavg);
title(str2);
datetick('x', 'dd HH:MM');
ylabel('Temp, deg C');
print
subplot(4,1,2)
plot(time,pres,'r');
datetick('x', 'dd HH:MM');
ylabel('Pres, hPa');
print
subplot(4,1,3)
plot(time,hum,'g');
datetick('x', 'dd HH:MM');
ylabel('RH, %');
print
subplot(4,1,4)
plot(time,spd,'m');
datetick('x','dd HH:MM');
ylabel('Wnd Spd, m/s');
print
xlabel(str);

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

채택된 답변

Jan
Jan 2014년 1월 20일
Did you try to set the size of the figure explicitly?
  댓글 수: 2
Marian
Marian 2014년 1월 21일
I thought that was what the -r100 code in the print statement was for? Otherwise, there was no other place where the code determines figure size... is there a way to do this?
Marian
Marian 2014년 1월 22일
Ok, I've figured out how to set the figure size and it finally worked! Thanks so much!! For anyone else reading this question: ... http://www.mathworks.com/help/matlab/creating_plots/changing-a-figures-settings.html#f3-137210 ...

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by