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