I would like to load and save my variables in Matlab like this:
[height, weight] = load('measurements.mat');
I believe this is not possible in Matlab.
Why do I want it like this?
1) I want to be able to store my filenames in strings, so for example
path = ...
measurementFile = [path '\measurements.mat'];
[height, weight] = load(measurementFile);
load measurementFile height weight
does not work.
2) I want to see if I load any variable which I don't use.
So suppose I had
load(measurementFile, 'height', 'weight', 'age');
But I don't use age. Then I want to get an warning in the editor.
If I had
[height, weight, age] = load(measurementFile);
I would get a warning, which is exactly what I want!
3) Using loaded variables in a parfor loop also gives an error.
load(measurementFile, 'height', 'weight');
BMI(ii) = weight(ii) / height(ii)^2;
gives an error:
Undefined function or method 'weight' for input arguments of type 'double'.
Solving it by using:
height = height;
weight = weight;
looks ugly to me.
How do you think about this?
Could this be new functionality in R2012b?