MATLAB Answers

Martin

Display Matrix when member of a class

Asked by Martin
on 27 May 2013

Hi!

I have a class containing two propoerties : InitialData is just an array, whereas Final is a 2*2 matrix. How can I ask Matlab to display the values of both these variables? Rather than

    InitialData: [2.2  12  3.4]
      FinalData: [2x2 double]

Thanks!

  0 Comments

Products

No products are associated with this question.

2 Answers

Answer by Image Analyst
on 27 May 2013
 Accepted answer

Maybe

disp(yourClassVariable.InitialData);
disp(yourClassVariable.FinalData);

Or you can leave off the disp(); so that you just have the names alone.

Or you can use fprintf():

fprintf('InitialData = %.1f %.1f %.1f\n', yourClassVariable.InitialData)
fprintf('FinalData:\n', yourClassVariable.FinalData)
fprintf('    %.1f %.1f\n', yourClassVariable.FinalData)

  0 Comments


Answer by Martin
on 28 May 2013

Thank you! :)

  0 Comments


Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today