printf - MATLAB: Printing comparative columns for elements from different vectors -


i´m trying printing comparative columns compare elements same index of 2 or 3 differents vector. illustrate question next example

>> = [5.47758 7.46578 3.45323] =  5.4776    7.4658    3.4532  >> b = [5.65432 4.45678 2.34789]  b =  5.6543    4.4568    2.3479 

now if write

>> sprintf('%.2f %.2f\n',a, b) 

i following response matlab

ans = 5.48 7.47 3.45 5.65 4.46 2.35` 

but way see presentation of values this

ans = 5.48 5.65   7.47 4.46  3.45 2.35 

how can use function sprintf (or other function or way) above representation? thank you.

you can fix problem concatenating a , b 1 2-by-3 matrix input argument:

>> sprintf('%.2f %.2f\n',[a; b])  ans =  5.48 5.65 7.47 4.46 3.45 2.35 

the sprintf function works reusing formatting string on , on traverses (in column order) elements of each of input arguments in order entered. that's why in example values of a printed, then values of b, instead of interleaving values of a , b.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -