How can I print the information (trainer, etc), I am not allow to used display?

1 次查看(过去 30 天)
Trainer = struct("Name", [Trai{1}], "Power_Level", [Trai{2}], ...
"Number_of_Pocket_Monsters",[Trai{3}], ...
"Pocket_Monster", [Trai{4}{1},Trai{4}{2},Trai{4}{3}], ...
"Number_of_Wins", [Trai{5}], "Number_of_Losses", [Trai{6}]);
Blastoise = struct("Name",[Poke{1}], "Power_Level",[Poke{4}], ...
"NickName",[Poke{7}],"Number_of_Wins",[Poke{10}],"Number_of_Losses",[Poke{13}]);
Charizard = struct("Name",[Poke{2}], "Power_Level",[Poke{5}], ...
"NickName",[Poke{8}],"Number_of_Wins",[Poke{11}],"Number_of_Losses",[Poke{14}]);
Venusaur = struct("Name",[Poke{3}], "Power_Level",[Poke{6}], ...
"NickName",[Poke{9}],"Number_of_Wins",[Poke{12}],"Number_of_Losses",[Poke{15}]);
%%
Table = struct2table(Trainer);

回答(1 个)

Walter Roberson
Walter Roberson 2023-4-7
Trai = {'Ash', 11, 5, {'Pich', 'Mozi', 'Thundar'}, 53, 18};
Trainer = struct("Name", [Trai{1}], "Power_Level", [Trai{2}], ...
"Number_of_Pocket_Monsters",[Trai{3}], ...
"Pocket_Monster", [Trai{4}{1},Trai{4}{2},Trai{4}{3}], ...
"Number_of_Wins", [Trai{5}], "Number_of_Losses", [Trai{6}]);
Trainer
Trainer = struct with fields:
Name: 'Ash' Power_Level: 11 Number_of_Pocket_Monsters: 5 Pocket_Monster: 'PichMoziThundar' Number_of_Wins: 53 Number_of_Losses: 18
TS = structfun(@(F) string(F), Trainer, 'uniform', 0);
arrayfun(@(A,B) fprintf("%s = %s\n", A, B{1}), string(fieldnames(TS)), cellstr(struct2cell(TS)));
Name = Ash Power_Level = 11 Number_of_Pocket_Monsters = 5 Pocket_Monster = PichMoziThundar Number_of_Wins = 53 Number_of_Losses = 18

类别

Help CenterFile Exchange 中查找有关 Communications Toolbox 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by