MATLAB Answers

User should choose the path for saving variable once

8 views (last 30 days)
Hello all, we are retrieving the result from the GUI developed by us and those results are stored in NOTEPAD with three different filenames, I should provide facility to the user to choose the path once later for saving other two files it has choose same path as default for the next time. i have provided the pseudo code
[fileName,pathName] = uiputfile('Coefficients.h');
file_path = fullfile(pathName,fileName);
fid1 = fopen(file_path, 'wt');
similarly parameters.h etc
i need to save file1 in user defined folder for eg. folder1 once saved while saving file2 it should not ask for the path, it should directly go and save in folder1 or the path should be taken directly to folder1 similarly as goes on


Stephen Cobeldick
Stephen Cobeldick on 8 Oct 2018
"...and those results are stored in NOTEPAD..."
Microsoft Notepad is an outdated and buggy text editor: it reads and displays text files. It is not a file format. Your data are stored as text files.
Stephen Cobeldick
Stephen Cobeldick on 8 Oct 2018
"i am storing in different format like .c and .h"
File extensions do NOT specify the file format. Consider that you take a .txt file and change its file extension to .doc: does this magically change the file format from text file to Word binary file? No, it does not. All it does is change the file extension. The file extension is totally irrelevant to the file format (apart from possibly confusing some Windows OS, but this is not the file format's fault).
Your .h and .c files are most likely text files. If you want to specify how the data are formatted in those files, that you need to give their specifications.

Sign in to comment.

Accepted Answer

Stephen Cobeldick
Stephen Cobeldick on 8 Oct 2018
Edited: Stephen Cobeldick on 8 Oct 2018
Following the description of uiputfile, try something like this:
txt = 'Select Parameter File';
[f1,p1] = uiputfile('*.h',txt);
[f2,p2] = uiputfile('*.h',txt,[p1,filesep]);
[f3,p3] = uiputfile('*.h',txt,[p2,filesep]);
Read the documentation and experiment until you get the desired effect.

  1 Comment

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!