From: Naftali Herscovici on
Hello,

I was wondering if Matlab accepts a form of the following (as shown it does not):

a=3.2;
b=5.69;
c=2.34;
i=1
s='help'

fprintf(%3f5.3 %i2 %s\n',a,b,c,i,s).

The emphasis is on %3f5.3
like in FORTRAN: 3f5.3
I have 11 real variables,text and integers to print on one row and I do not want to make a long <fprintf> command

Tx
T
From: TideMan on
On Jun 18, 8:23 am, "Naftali Herscovici" <tul...(a)hotmail.com> wrote:
> Hello,
>
> I was wondering if Matlab accepts a form of the following  (as shown it does not):
>
> a=3.2;
> b=5.69;
> c=2.34;
> i=1
> s='help'
>
> fprintf(%3f5.3 %i2 %s\n',a,b,c,i,s).
>
> The emphasis is on %3f5.3
> like in FORTRAN: 3f5.3
> I have 11 real variables,text and integers to print on one row and I do not want to make a long <fprintf> command
>
> Tx
> T

Oh dear, mentioning one of the excellent features of Fortran that is
unfortunately not available in either C or Matlab is likely to re-
start a war on this forum.

You need to do this:
fmt=[repmat('%5.3f ',1,3) '%2i %s\n'];
fprintf(fmt,a,b,c,i,s);

Compared to Fortran, it's long-winded, I know, but it's one of the
downsides of C and Matlab.
From: Jan Simon on
Dear Naftali,

> I was wondering if Matlab accepts a form of the following (as shown it does not):
>
> a=3.2;
> b=5.69;
> c=2.34;
> i=1
> s='help'
>
> fprintf(%3f5.3 %i2 %s\n',a,b,c,i,s).
>
> The emphasis is on %3f5.3
> like in FORTRAN: 3f5.3
> I have 11 real variables,text and integers to print on one row and I do not want to make a long <fprintf> command

I assume, writing this post took more time than writing a "long" fprintf command.

Jan
From: dpb on
TideMan wrote:
> On Jun 18, 8:23 am, "Naftali Herscovici" <tul...(a)hotmail.com> wrote:
....

> Oh dear, mentioning one of the excellent features of Fortran that is
> unfortunately not available in either C or Matlab is likely to re-
> start a war on this forum.
....

Chuckle...I promise as long as it isn't said to be "obsolete" by
somebody who shall be nameless... :)

--