Clear Filters
Clear Filters

How to export variables into excel file continuously?

4 views (last 30 days)
Hello,
I am using App Designer and I was wondering how I would be able to export the variables created from the information inputted by the user into a premade excel file that would add on each user's new inputs. I would need to export to two excel files, one that just collects used patient IDs w/ dates (named Used Patient Ids) and then another that collects all the variables (named Patient Data).
I would like to be able to do this when I press the save button, which I've inserted below:
% Button pushed function: SaveButton
function SaveButtonPushed(app, event)
PatientID = app.PatientIDEditField.Value;
FirstName = app.FirstName;
LastName = app.LastName;
DOB = app.DOB;
filename = sprintf('PatientID_%s', PatientID);
if ~exist(filename, 'file')
save(filename,'PatientID','FirstName','LastName','DOB');
else
error('%s already exists. Try again.', filename)
end
end
I don't have any code written yet that would note the day the data was put in if that would be needed.

Answers (1)

Walter Roberson
Walter Roberson on 19 Sep 2022
Unfortunately, in your R2019a release you have to either keep track of the current position, or else each time you went to write you would have to figure out where the current end of data is.
If you were using R2020a or later, you would be able to use the option 'WriteMode', 'append' and it would automatically position so it was adding new rows.

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!