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
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com