f



fprintf['text' vector 'text' vector]???

Hello,

Could someone tell me how I can print this using fprintf, I probably missed an insturction somewhere:

DE = [  0.5000 0.7000 0.9000; 2.0000 3.0000 4.0000 ]; > CHECK)

With A = 0.5 0.7 0.9 and B 2 3 4

using fprintf in one line. Right now this is what I do:

fid = fopen ('test.txt', 'w');

fprintf(fid,'DE    = [ ')
fprintf(fid,'%6.4f',A)
fprintf(fid,'; ')
fprintf(fid,'%6.4f',B)
fprintf(fid,' ]; > CHECK)')

fclose(fid);

Seems kind of exaggerated. I was hoping to end up with something like:

fid = fopen ('test.param', 'w');
fprintf(fid,'DE    = [ % 6.4f ; % 6.4f ] > lookupTable_BUS)' , A, B)
fclose(fid);

But  this doesn't work.

Thanks,
Soeren
0
Sören
7/1/2010 2:46:07 PM
comp.soft-sys.matlab 211264 articles. 25 followers. lunamoonmoon (257) is leader. Post Follow

2 Replies
1147 Views

Similar Articles

[PageSpeed] 17

"Sören Sieberling" <seuren83@hotmail.com> wrote in message <i0i9nf$hnj$1@fred.mathworks.com>...
> Hello,
> 
> Could someone tell me how I can print this using fprintf, I probably missed an insturction somewhere:
> 
> DE = [  0.5000 0.7000 0.9000; 2.0000 3.0000 4.0000 ]; > CHECK)
> 
> With A = 0.5 0.7 0.9 and B 2 3 4
> 
> using fprintf in one line. Right now this is what I do:
> 
> fid = fopen ('test.txt', 'w');
> 
> fprintf(fid,'DE    = [ ')
> fprintf(fid,'%6.4f',A)
> fprintf(fid,'; ')
> fprintf(fid,'%6.4f',B)
> fprintf(fid,' ]; > CHECK)')
> 
> fclose(fid);



%DE = [ 0.5000 0.7000 0.9000; 2.0000 3.0000 4.0000 ]; > CHECK)

A = [0.5, 0.7, 0.9];
B = [2, 3, 4];

fid = fopen('test4Soren.txt', 'w');

fprintf(fid,['DE = [' sprintf(' %6.4f',A) ';' sprintf(' %6.4f',B) ']; > CHECK)'])

fclose(fid);
0
7/1/2010 3:01:21 PM
Hey Sean,

Thanks.
0
Sören
7/1/2010 4:07:04 PM
Reply: