I want to convert the cell array to struct but I dont know how to use the cell2struc command. I am new, please help me
4 次查看(过去 30 天)
显示 更早的评论
patients = {'LastName','FirstName','Age','Weight','Diagnosis';'Johnston','John','69','230','Pulmonary Hypertension';'Lee','Kyle','34','168','Type II Diabetes';'Miller','Fionna','55','194','Congestive Heart Failure'}
structArray = cell2struct(patients)
0 个评论
采纳的回答
Yusuf Suer Erdem
2021-12-3
Hi Manh, try these codes below. After running the code open s matrix there and this will be your structure. To use cell2struct command you need give information of classes and dimensions. Good luck.
clc; clear; close all;
patients = {'Johnston','John','69','230','Pulmonary Hypertension';'Lee','Kyle','34','168','Type II
Diabetes';'Miller','Fionna','55','194','Congestive Heart Failure'};
f = {'LastName','FirstName','Age','Weight','Diagnosis'};
s = cell2struct(patients,f,2);
7 个评论
Walter Roberson
2021-12-3
If your workspace is full of matrices from other scripts... perhaps you should be writing functions instead of scripts.
Yusuf Suer Erdem
2021-12-3
@Walter Roberson that is true. using functions saves you from dirty workspace.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!