Error with strings when creating filename in Matlab on hpc

24 Views Asked by At

I am running a matlab script on an hpc which save various variables using the following command:

fname = char(['~/Documents/MATLAB/PROCESSING/', strtrim(participant), '/', strtrim(participant),strtrim(task), 'PRO.mat']);

However, I get the following error in that it can't find the folder as long spaces are added to the variable 'participant'.

Error using save
Cannot create '                                       HC_s02
resting                                 PRO.mat
' because '/home/eb857/Documents/MATLAB/PROCESSING/HC_s02
' does not exist.

Error in LUMO_finalPipeline (line 163)
    save(fname, 'dat', '-v7.3');

I have tried doing the following:

participant = strrep(participant, ' ', '');
task = strrep(task, ' ', '');

But I still get the error. Can anyone help me? Thanks!

0

There are 0 best solutions below