How can I save the data from my function as a new .mat file?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Himangshu
am 29 Apr. 2023
Kommentiert: Himangshu
am 29 Apr. 2023
This is my code snippet:
[filepath, name, ext] = fileparts(filename);
newFilename = fullfile(filepath, name , '_RT.mat');
disp(newFilename)
save(newFilename, 'AudioRT', 'VisualRT', 'SOA')
This is the result:
/MATLAB Drive/CHECK/Participant/_RT.mat
Error using save
Cannot create '_RT.mat' because '/MATLAB Drive/CHECK/Participant' does not exist.
Error in CongruentRT (line 42)
save(newFilename, 'AudioRT', 'VisualRT', 'SOA')
But I expect this:
/MATLAB Drive/CHECK/Participant_RT.mat % "/" need not be there
Then, I assume my files would get saved and it won't throw this error.
0 Kommentare
Akzeptierte Antwort
Stephen23
am 29 Apr. 2023
Change
newFilename = fullfile(filepath, name , '_RT.mat');
to
newFilename = fullfile(filepath, [name,'_RT.mat']);
% ^ ^
3 Kommentare
Stephen23
am 29 Apr. 2023
Aaah, you are actually using strings. It helps when you provide this kind of important information.
Try STRCAT:
newFilename = fullfile(filepath, strcat(name,'_RT.mat'))
% ^^^^^^^ ^
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Workspace Variables and MAT Files finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!