matlabnumber-formattingoutput-formatting

Display multiple values in one line


I'm new to MATLAB. I have two values x and y. Both of them contain values with unknown accuracy. The problem: How could I display them both in one row with 2 digits after comma? Like:

x<tabulation or stack of spaces>y<then goes new line>

Example

RAW data

  0,324352           0,75234
  1,563              3,4556

Expected output

0,34                0,75
1,56                3,45

Upd: for one value it works well

disp('x=' num2str(x,3));

Purpose is: display TWO values on one row with the new line symbol


Solution

  • The answer is:

    disp(num2str([x y],3));
    

    The 3 value means - max.quanity of symbols after comma including it(am I wrong? just thoughts)

    Another Idea:

    Somehow represent X and Y as array values and then display them.