Path: news.mathworks.com!not-for-mail
From: "Ashley " <whitney.rawls@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Issues Writing to File
Date: Sat, 7 Nov 2009 14:08:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 63
Message-ID: <hd3v01$84l$1@fred.mathworks.com>
References: <hd3sl1$esl$1@fred.mathworks.com> <hd3uer$cnn$1@news.eternal-september.org>
Reply-To: "Ashley " <whitney.rawls@gmail.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257602881 8341 172.30.248.38 (7 Nov 2009 14:08:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 7 Nov 2009 14:08:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2080389
Xref: news.mathworks.com comp.soft-sys.matlab:583216


dpb <none@non.net> wrote in message <hd3uer$cnn$1@news.eternal-september.org>...
> Ashley wrote:
> > I'm having trouble writing to a file using fprintf. The issues is I
> > need to write lines like:
> > fprintf('     name='C:/Documents and ...
> 
> ...
> 
>  >> sprintf('%s','It''s an embedded ''.')
> ans =
> It's an embedded '.
>  >>
> 
> Double up on the apostrophes is one way; another is to insert the 
> numeric values w/ strrep in an existing string at a desired location or 
> use strcat or , to build the string.
> 
>  >> pstrphe = double('''')
> pstrphe =
>      39
>  >>  char(pstrphe)
> ans =
> '
>  >> s = ['That', char(pstrphe), 's a string.']
> s =
> That's a string.
>  >>
> 
> for example.  repmat() sometimes comes in handy for repeated strings as 
> well.
> 
> help strfun
> 
> to see the full ML repertoire from which to choose...
> 
> BTW, I assume you did get the max stress data read correctly?
> 
> --

Yes thank you I did get the max stress read correctly although I used a different method.  Although what you suggested worked I was worried that it would fail if the max stress was for some reason written on a different line.  A friend helped me write the following:

fid=fopen(filename,'r');
eofstat=0;

while (eofstat == 0);
    
   tline = fgetl(fid);
   [a,b] = size(tline);
    
    if b >= 9 & tline(1:9) == '  Maximum';
        find = 1;
        values = sscanf(tline, '%s %f' );
        max = values(8);
        
       break
    end
    eofstat = feof(fid);
end

fclose(fid);

Which works very well and doesn't care which line the max stress is writtne on. Thanks again for all your help.
Ashley