MATLAB Answers

How to "quicksave" a file in app designer?

3 views (last 30 days)
Huguette Djoumsap Takam
Huguette Djoumsap Takam on 30 Jul 2021
Hi Community,
i devellop a little app for kinematic simulation and can save the simulation result. But i have an issue with my "quicksave" button.
The role of the "quicksave" button is to first save the simulation result as an normal save function. Then if i change something in the simuation then i need to save the changes without giving one more time a new pfad. It means, that "Quicksave"-function needs to remenber the save-path and if it exists save in that path.
Now i wrote this code, but everytime i clicked on the "quicksave"-button i still need to choose the path. Can anyon have an idea, where something i'm doing wrong?
Thanks in advance for the help
% Button pushed function: SaveButton
function SaveButtonPushed(app, event)
if app.isNotValid
dStr = string(datestr(now(),'yyyy-mm-dd_HH-MM'));
sysVar = app.System;
sysName = app.System.Name;
[file,path] = uiputfile(".mat","Save AnimTronics System",sysName + "_" + dStr);
% if isnumeric(file) && file == 0
% return
fileName = fullfile(path,file);
% File exists
if exist(fileName,'file')
%if file does not exist

Answers (1)

Matt J
Matt J on 30 Jul 2021
Edited: Matt J on 30 Jul 2021
The 3rd argument to uiputfile should end with a path separation character:
[file,path] = uiputfile(".mat","Save AnimTronics System",sysName + "_" + dStr + filesep);
Huguette Djoumsap Takam
Huguette Djoumsap Takam on 15 Aug 2021
I have another question:
how can i, for the first step, save the filepath in a private property and then check if there is anything in the property?
If there is something, then the current path will be use for saving one more time. But if there is nothing in the property, the save function will be call.
Just need some ideas.
Thanks for helping

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by