Thread Subject: hgload script vs commandline

Subject: hgload script vs commandline

From: Dan Haeg

Date: 7 Jul, 2008 21:56:02

Message: 1 of 1

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')

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com