saveas vs. "File->Save as"

8 Ansichten (letzte 30 Tage)
Marco
Marco am 6 Sep. 2013
Kommentiert: Yogesh Babu am 28 Feb. 2014
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 Kommentar
Yogesh Babu
Yogesh Babu am 28 Feb. 2014
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?

Melden Sie sich an, um zu kommentieren.

Antworten (3)

Thomas
Thomas am 6 Sep. 2013
try
saveas(gcf,'mypicture.fig')
  3 Kommentare
Jan
Jan am 9 Sep. 2013
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 am 10 Sep. 2013
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

Melden Sie sich an, um zu kommentieren.


Jan
Jan am 8 Sep. 2013
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 am 9 Sep. 2013
For an alternative, try using hgsave() instead of saveas()

Kategorien

Mehr zu Printing and Saving finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by