How to print Structure content to command window?

24 ビュー (過去 30 日間)
khalid
khalid 2014 年 12 月 7 日
回答済み: Image Analyst 2014 年 12 月 7 日
How do you print structure content to the command window?
fprintf is not working
??? Error using ==> fprintf Function is not defined for 'cell' inputs.

回答 (1 件)

Image Analyst
Image Analyst 2014 年 12 月 7 日
You need to printf each member of the structure or the contents of each cell according to what data type that member or cell is. For example
ca = {'abc', 24}; % Define a cell array
fprintf('ca{1} = %s\nca{2} = %d\n', ca{1}, ca{2});
s.number = 42; % Define a structure.
s.string = 'def';
fprintf('s.number = %d\ns.string = %s\n', s.number, s.string);

カテゴリ

Help Center および File ExchangeWhos についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by