[Scilab-users] Basic query - mprintf

Stefan Du Rietz sdr at durietz.se
Wed Jan 11 22:24:56 CET 2023


On 2023-01-11 00:11, Samuel Gougeon wrote:
> Le 07/04/2022 à 09:50, Lester Anderson a écrit :
>> Hello all,
>>
>> Very basic query but how do you print all the values from a result via 
>> mprintf?
>>
>> e.g.
>>
>> fac = factor(1729)
>> 7 13 19
>>
>> mprintf('Factors of 1729 are: %d\n', fac)
>> just prints 'Factors of 1729 are: 7
>>
> You may also use a Fortran syntax -- that supports automatic inline 
> iterations, unlike C syntaxes -- instead of a  C one:
> 
> --> fac = factor(1729);
> --> write(%io(2), fac, "(''Factors of 1729 are:'', 10(i2,2x))")
> 
> Factors of 1729 are: 7  13  19
> 
> Samuel
> 
> PS : i no longer receive messages from users@ since 2022-10-05 (last 
> received).
> So for the time being, i answer to old threads, to not break recent ones 
> to which i can't reply, just read archives.
> 
> 
Too print all elements, the argument must be a column vector: fac'
And to avoid repeating the first wording, you can print it separately:

--> mprintf("Factors of 1729 are: "), mprintf("%d  ", fac')
Factors of 1729 are: 7  13  19

Stefan







More information about the users mailing list