Save selected variables into a file

4 views (last 30 days)
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 1x12 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?
  1 Comment
Image Analyst
Image Analyst on 5 Apr 2014
If you don't use parentheses to use the "function" form of save, then it thinks fname is the actual filename itself rather than the name of a variable containing the filename. Confusing, I know - that's way I nearly always use the function form of functions except for really simple ones like axis, cla, etc.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 5 Apr 2014
save(fname, 'names', 'onsets', 'durations')

More Answers (0)

Categories

Find more on Environment and Settings in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!