try catch does not catch an error in save function
Consider
try
statements
save("/gpfs/home/jk23bd/kimjmp_25may2024/MATLAB/kimscalprr.mat","kimScalingPriors");
catch ME
disp(ME.message)
end
where statements is a block of codes. I’m sure that statements is a good block of codes, i.e., without errors. This leads to no display of message, and it fails to save (because the directory does not exist).
On the other hand,
statements
try
save("/gpfs/home/jk23bd/kimjmp_25may2024/MATLAB/kimscalprr.mat","kimScalingPriors");
catch ME
disp(ME.message)
end
Now, this does lead to displaying
Cannot create ‘kimscalprr.mat’ because ‘gpfshomejk23bdkimjmp_25may2024MATLAB’ does not exist.
as it should. I’m finding that save has a lot of issues besides this, but this seems the most basic. Can anyone tell me why this difference occurs?
Thank youConsider
try
statements
save("/gpfs/home/jk23bd/kimjmp_25may2024/MATLAB/kimscalprr.mat","kimScalingPriors");
catch ME
disp(ME.message)
end
where statements is a block of codes. I’m sure that statements is a good block of codes, i.e., without errors. This leads to no display of message, and it fails to save (because the directory does not exist).
On the other hand,
statements
try
save("/gpfs/home/jk23bd/kimjmp_25may2024/MATLAB/kimscalprr.mat","kimScalingPriors");
catch ME
disp(ME.message)
end
Now, this does lead to displaying
Cannot create ‘kimscalprr.mat’ because ‘gpfshomejk23bdkimjmp_25may2024MATLAB’ does not exist.
as it should. I’m finding that save has a lot of issues besides this, but this seems the most basic. Can anyone tell me why this difference occurs?
Thank you Consider
try
statements
save("/gpfs/home/jk23bd/kimjmp_25may2024/MATLAB/kimscalprr.mat","kimScalingPriors");
catch ME
disp(ME.message)
end
where statements is a block of codes. I’m sure that statements is a good block of codes, i.e., without errors. This leads to no display of message, and it fails to save (because the directory does not exist).
On the other hand,
statements
try
save("/gpfs/home/jk23bd/kimjmp_25may2024/MATLAB/kimscalprr.mat","kimScalingPriors");
catch ME
disp(ME.message)
end
Now, this does lead to displaying
Cannot create ‘kimscalprr.mat’ because ‘gpfshomejk23bdkimjmp_25may2024MATLAB’ does not exist.
as it should. I’m finding that save has a lot of issues besides this, but this seems the most basic. Can anyone tell me why this difference occurs?
Thank you try, catch, error, save MATLAB Answers — New Questions