Display Matrix when member of a class

2 次查看(过去 30 天)
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!

采纳的回答

Image Analyst
Image Analyst 2013-5-27
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)

更多回答(1 个)

Martin
Martin 2013-5-28
Thank you! :)

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by