saveas vs. "File->Save as"

조회 수: 12 (최근 30일)
Marco
Marco 2013년 9월 6일
댓글: Yogesh Babu 2014년 2월 28일
Hi,
I am modifying the data tips to be visualized in the data cursor. Everything works fine, but when I save the figure .fig with saveas I lose all the changes I have done to the data tips.
Interestingly if I use instead the "File-> Save as" manually from the figure GUI, the changes to the figure are preserved. Am I missing something in the saveas command? The code is something like this:
figA=figure('name','Test');
h=plot(....);
addTagCursor(h,...);
hold on
h=plot(...);
addTagCursor(h,...);
saveas(figA, 'mypicture.fig');
Thanks for help!
  댓글 수: 1
Yogesh Babu
Yogesh Babu 2014년 2월 28일
Hi, plot(Resultsforyyyy);figure(gcf); saveas(gcf,'Peile.fig') In the above line my pelie.fig is fixed one i want to use that with respect to the data i am plotting.Is that possible?

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

답변 (3개)

Thomas
Thomas 2013년 9월 6일
try
saveas(gcf,'mypicture.fig')
  댓글 수: 3
Jan
Jan 2013년 9월 9일
If you post some code, which runs after a copy&paste, we could try to reproduce the problem. Hiding the interesting parts by "..." does not allow to test exactly what's going on.
Marco
Marco 2013년 9월 10일
Hi, Thanks for help! I have tried many option, e.g. saveas(gcf,..), hgsave, etc. but with no luck so far. When I open the saved picture all the data tips I modified disappear.
Here is the code:
function test
a=[495156 495216 495276 495476 495516 495576 495676 495716 526396 542016]
b=[9790787 9798246 9805705 9836650 9843961 9855805 9878359 9883467 16173228 20990681]
c=[3 5; 6495542 7495542; 9848605 19848605; 432 657]
figB=figure('name','Test');
h=plot(a,ones(1,length(a)),'*r');
addTagCursor1(h, [cellstr(num2str(b'))... repmat(cellstr(num2str(-1)),length(cellstr(num2str(b'))),1)... repmat(cellstr(num2str(-1)),length(cellstr(num2str(b'))),1)]);
hold on
h=plot(c(2,:),ones(1,size(c,2)),'hk');
addTagCursor1(h, [cellstr(num2str(c(3,:)'))... cellstr(num2str(c(1,:)'))... cellstr(num2str(c(4,:)'))]);
hold on
saveas(figB,strcat(pwd,'\test.fig'));
end
function addTagCursor1(h,data)
set(h,'userdata',data)
dcmH = datacursormode(gcf);
set(dcmH, 'enable','on', 'UpdateFcn',@cursorUpdateFcn1, 'NewDataCursorOnClick',false);
end
function output_txt = cursorUpdateFcn1(obj,event_obj)
pos = get(event_obj,'Position');
labels = get(get(event_obj,'Target'),'UserData');
xvals = get(get(event_obj,'Target'),'XData');
yvals = get(get(event_obj,'Target'),'YData');
datapoint = find( (xvals==pos(1))&(yvals==pos(2)) );
output_txt = {['Time: ',num2str(pos(1))];... ['Y_axis: ',num2str(pos(2))];... ['Log Line: ',labels{datapoint,1}];... ['Value1: ',labels{datapoint,2}];... ['Value2: ',labels{datapoint,3}]};
end

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


Jan
Jan 2013년 9월 8일
You can use the debugger to check, what's going on inside saveas. Simply set a breakpoint inside this function, step through the code line by line and find out, which command influences the data tips.

Ilham Hardy
Ilham Hardy 2013년 9월 9일
For an alternative, try using hgsave() instead of saveas()

카테고리

Help CenterFile Exchange에서 Standard File Formats에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by