|
I have some fig files saved with data I wish to put in
excel. I used hgload in a loop to open the fig files and
retrieve the x-data and y-data. I have trouble when I try to
get the title string of the current axes in a script. It
works fine from the commandline though. I am just wondering
why it does not work, I only had 6 figures to convert so the
commandline workaround was ok but in the future I may need
to use similar code so I want to know the correct way to do it.
Thanks for any advise you can give.
Dan Haeg
Here is the code I tried:
range1 = {'a1','c1',etc};%title range
range = {'a2','c2',etc};%header range
RANGE = {'a1','c1',etc};%raw data range
s=dir('*.fig');
%trying to tell matlab variable types
tit='trial';
ff1='trial';
x=1;y=1;
for ind=1:length(s)
h=hgload(s(ind).name);
[x,y]=getfigdatakemp;%a function to retrieve x-data and
%y-data from the current figure
%below must be run from the commandline
h1=get(gca,'title');
tit=get(h1,'string'); %title string
ff1=sprintf('%s',tit');
for lame=1:10 %stupid way to remove extra spaces
ff1=strrep(ff1,' ',' ');
end
%here I run the above code at the commandline
keyboard
xlswrite('raw.xls',{ff1},1,range1{ind})
xlswrite('raw.xls',{'flow','dp'},1,range{ind})
xlswrite('raw.xls',[x',y'],1,RANGE{ind})
end
winopen('raw.xls')
|