Home > Mobile >  fprintf vectors side by side and name each
fprintf vectors side by side and name each

Time:01-05

i got a problem with using disp to display 3 different vectors side by side. My output is as follows:

 1.8601    4.0025    4.8918
 3.8949    2.0025    4.8662
 2.1541    1.6125    1.4036
 3.2573    5.3038    3.2280
 5.4745    3.0017    3.5468
 4.8826    4.6000    1.9313
 7.3062    5.5444    4.4598
 8.8391    7.6922    5.7983

Now i want to name each column like:

dN1 = 1.8601      dN2 = 4.0025      dN3 = 4.8918
      3.8949            2.0025            4.8662
      2.1541            1.6125            1.4036
      3.2573            5.3038            3.2280
      5.4745            3.0017            3.5468
      4.8826            4.6000            1.9313
      7.3062            5.5444            4.4598
      8.8391            7.6922            5.7983

I tried to use disp([dN1,dN2,dN3]), but i wonder how i can print these "dN1 =" at the very first line and how i can seperate the vectors by a certain number of spaces.

I'm very grateful for any help.

CodePudding user response:

Grouping the variables under a single table would let you leverage the native table display style

disp(table(dN1,dN2,dN3))

Output:

     dN1       dN2       dN3  
    ______    ______    ______
    1.8601    4.0025    4.8918
    3.8949    2.0025    4.8662
    2.1541    1.6125    1.4036
    3.2573    5.3038     3.228
    5.4745    3.0017    3.5468
    4.8826       4.6    1.9313
    7.3062    5.5444    4.4598
    8.8391    7.6922    5.7983
  •  Tags:  
  • Related