How can I do this?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Joao Joao
il 4 Gen 2022
Commentato: Joao Joao
il 6 Gen 2022
Hi, I hope you are doing well in this pandemic. I am new in matlab, and I would like to know how do I develop a script that exemplifies the use of a certain function. If you could give me an example of any function I would appreciate it. Thanks
2 Commenti
Risposta accettata
Scott Satinover
il 4 Gen 2022
So the input argument is the table from the excel file. So this might work if the excel file is in the same folder as the function and this script:
file = 'filename'; % Use the name of the excel file, and omit the extention.
table = table2struct(readtable(file)); % The script updates a struct, so read in the excel file as a table and convert to a struct.
table = add_patient(table); % Run the function on the struct and update the table.
writetable(table,file); % Overwrite the excel file.
4 Commenti
Scott Satinover
il 5 Gen 2022
You need to retrieve the results for a given patient, and the results are found on the second tab. First, pull the results from the spreadsheet on the second tab using the name-value argument the specifies the sheet you want to retrieve, using the Sheet name-value argument. Without this argument, the readtable function only reads the first sheet, so you need to specify it here:
file = "Data";
exams = readtable(file,Sheet=2);
The readtable function returns most text in cells as part of a cell array, which you can't sort or filter data with. But the data you want to retrieve is based on data that is a cell array. To work around this, convert the PatientID column into a string array with the string function:
exams.PatientID = string(exams.PatientID);
Now, filter your results and create a new table. Specify the patient ID as a string, and then use logical expressions to filter your results. For example, if you want to look up the records for P00000008, enter this:
ID = "P00000008";
filtered_exams = exams(exams.PatientID == ID);
Then, to return the latest entry, use index notation on the filtered table:
filtered_exams(end,:)
To learn more about this functionality, go through the MATLAB Onramp and MATLAB Fundamentals training.
Più risposte (1)
Scott Satinover
il 4 Gen 2022
Modificato: Scott Satinover
il 4 Gen 2022
I recommend you take a look at this category:
If you want a more interactive learning experience, take a look at the MATLAB onramp tutorial:
It's super helpful for learning the basics of MATLAB.
Vedere anche
Categorie
Scopri di più su Startup and Shutdown in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!