Strange behaviour of 'saveas' function

조회 수: 3 (최근 30일)
Eugenio
Eugenio 2012년 7월 4일
I've a complex vector of 409600 elements. I do the scatterplot of the elements and then save as jpg image 600 x 800.
% iq is the name of the vector
figure('position',[1,1,800,600]);
plot(imag(iq),real(iq),'r-*');
title('SCATTERPLOT');
saveas(gcf,'scatterplot.jpg', jpg);
The result is:
??? Error using ==> plot
Invalid first data argument
Error in ==> scatterplot at 121
plot(yy, zeros(1,len_yy), plotstring);
Error in ==> print at 2
scatterplot(in,1,1,'k-o');
Error in ==> saveas at 154
print( h, name, ['-d' dev{i}] )
Is very annoying because sometimes it works, sometimes doesn't; and I can't understand the reason. Plus, if I save in 'fig? format it always works.
saveas(gcf,'scatterplot','fig'):
Can somebody help me to solve this easy code??

답변 (2개)

Image Analyst
Image Analyst 2012년 7월 4일
By the way, it's strange that the line it complains about
plot(yy, zeros(1,len_yy), plotstring);
is not in the code you posted. Why is that? What is line 121 of your scatterplot.m? Or actually, what is yy and len_yy there when it crashes there? Do you know how to use the debugger to set breakpoints and examine variables?

Eugenio
Eugenio 2012년 7월 4일
Hi Analyst, I don't know why during the execution Matlab goes execute scatterplot.m script. I usually test this kind of script on the workspace, and so I've never debugged it. I did it right now, and I've realized that I've created an m script called "print.m" that has benn called instead of "print.m" of graphic toolbox. So the code I've posted works only if i do not use the folder with my print.m as "Current Folder" path. Problem is near to be solved..thank you!

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by