MATLAB: Save selected variables into a file

save

Hi,
I have what seems to be a very simple problem but I just can't figure it out. I have a number of variables including 3 specific variables: names, onsets, and durations. All three of these variables are 1×12 cell. I want to save these three variables into a .mat file. Since this is a loop, previously I have specified the file name (fname=[Q{i} '_' 'WM' '_' Block{m} '.mat'];). I tried save fname names onsets durations but this incorrectly gives me fname.mat.
Could anyone help?

Best Answer

save(fname, 'names', 'onsets', 'durations')