필터 지우기
필터 지우기

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

조회 수: 1 (최근 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'}
patients = 4×5 cell array
{'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)
Error using cell2struct
Not enough input arguments.

채택된 답변

Yusuf Suer Erdem
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
Walter Roberson 2021년 12월 3일
If your workspace is full of matrices from other scripts... perhaps you should be writing functions instead of scripts.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by