newfilename is a variable in your workspace when you define it as
newfilename = fullfile(newsubfolder, filenamei);
In your first argument to save(), you say "newfilename.mat", which attempts to access the mat field of object newfilename. Hence the error Attempt to reference field of non-structure array.
Try this syntax instead:
Or if you really want to tag ".mat" on the end explicitly:
save([newfilename,'.mat'],'PIN');
1 Comment
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/252884-how-to-save-a-structure-as-mat#comment_1228232
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/252884-how-to-save-a-structure-as-mat#comment_1228232
Sign in to comment.