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

1 view (last 30 days)
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
.

Answers (3)

Jeremy
Jeremy on 4 Dec 2019
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 on 5 Dec 2019
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 on 5 Dec 2019
OK, got it with array2table
Thank you!!

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!