How to include string + numbers in a table using a for...end routine

1 回表示 (過去 30 日間)
giora landesberg
giora landesberg 2019 年 12 月 4 日
回答済み: giora landesberg 2019 年 12 月 5 日
Dear experts,
I am a physician and a poor matlab programmer. Nevertheless, I am trying to constract a program that automatically reads multiple excel files, each containing data from exercise stress tests of patients.
I have programmed already the routine that reads nicely one such excel file and extracts the following variables:
Results=[Name, ID, Date, Age, sex, ESTdur, TargetHR, METs, STlevel, STslope, HR_EST, SBP_EST, DBP_EST]
This is an output of one patient.
Name, ID, Date, Age, sex, ESTdur, TargetHR, METs, STlevel, STslope, are all string variables
HR-EST, SBP_EST and DBP_EST are 3 numeric arrays, each containing 26 numbers of heart rate, systolic and diastolic blood pressures, all converted to cells (or strings).
I am trying to collect the above Results output for many patients (thousands) and put all of the in a table such that each patient is one raw.
I wrote a for.....end routine that can read many excel files.
My problem however is that when I try to include each patient in the matrix FResults by: FResults(f,:)=Results
I get an error message of mismatch : "Conversion to double from cell is not possible."
How should I do that properly??
Thank you in advance. Giora
.

回答 (3 件)

Jeremy
Jeremy 2019 年 12 月 4 日
It sounds like you might want to use the command
readtable
This will read your entire spreadsheet as a table data type

giora landesberg
giora landesberg 2019 年 12 月 5 日
Hi Jeremy,
Thank you for your idea.
II have read the table already and extracted all the data I need from the table,
Now I need to generate another spreadsheet in which every patient's data is in one raw only.
I have done that too.
Results=[Name, ID, Date, Age, sex, ESTdur, TargetHR, METs, STlevel, STslope, HR_EST, SBP_EST, DBP_EST]
Now in a for....end loop I want to read hundreds of spreadsheets, extract the same data from all of them and include each patient (raw) in the ndw table.
My problem is that when I assign each raw with the changing variable:
FResults(f,:)=Results (f being the index of the new raw)
I get an error mesage. It expects FResults(f,:) to be of a numeric form and not string or table.
Any idea??
Thanks, Giora

giora landesberg
giora landesberg 2019 年 12 月 5 日
OK, got it with array2table
Thank you!!

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by