help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Repeated fields in printf


From: Søren Hauberg
Subject: Re: Repeated fields in printf
Date: Fri, 27 Aug 2010 08:08:37 +0200

tor, 26 08 2010 kl. 18:57 -0700, skrev Mike B.:
> When using printf/sprintf/fprintf is it possible to specifiy a field is 
> repeated, for example something like:
> 
> printf( "3*%3d", 100*rand( 1, 3 ) )
> 
> would use three fields each of type %03d. this is instead of 
> 
> printf( "%3d %3d %3d", 100*rand( 1, 3 ) )

I don't think so, but you can use 'repmat':

  printf (repmat ("%d ", 1, 3), 100*rand (1, 3))

In this specific case, you can also just do

  printf ("%d ", 100*rand (1, 3))

Søren



reply via email to

[Prev in Thread] Current Thread [Next in Thread]