Borrar filtros
Borrar filtros

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 visualización (últimos 30 días)
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.

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by