- Use the fullfile function: to create the full path to your file.
- folder = 'C:\path\to\your\folder'; % Define your desired folder
- filename = 'mydata.mat'; % Define the desired filename
- fullFileName = fullfile(folder, filename);
- Use the save command: with the fullFileName.
- save(fullFileName, 'variable_to_save');
- Call the uiputfile function: to open a dialog box for the user to specify a file.
- [filename, pathname] = uiputfile({'*.mat','MAT-files (*.mat)'; '*.*','All Files (*.*)'},'Save File As');
- Construct the full file path: using the returned pathname and filename.
- fullFileName = fullfile(pathname, filename);
- Save the file: using the fullFileName.
- save(fullFileName, 'variable_to_save');