5. You want to save only variables a and b from your workspace to a file named myvars.mat. Which command should you use?
hard
A. save myvars.mat a b
B. save('myvars.mat', 'a', b)
C. save('myvars.mat')
D. save('myvars.mat', a, b)
Solution
Step 1: Recall save syntax for specific variables
To save specific variables, list their names without quotes after the filename without parentheses.
Step 2: Analyze options
save myvars.mat a b uses correct syntax: save myvars.mat a b. save('myvars.mat', 'a', b) uses quotes but parentheses, which is invalid syntax in MATLAB. save('myvars.mat') saves all variables. save('myvars.mat', a, b) passes variables as values, which is incorrect.
Final Answer:
save myvars.mat a b -> Option A
Quick Check:
Use save filename var1 var2 to save specific variables [OK]
Hint: Use save filename var1 var2 without parentheses [OK]
Common Mistakes:
Using parentheses with save command
Putting variable names in quotes inside parentheses
Saving all variables unintentionally
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.