3

I have some mat files with large number of variables saved in it. So I only want to load a subset of the variables. For example, if I want to load

vars = {'x', 'y', 'z'}

I know I can explicitly do

a = load('filename.mat', 'x', 'y', 'z')

but the vars list can get long and I need to load multiple files, so I can't explicitly list out vars list every time. Is there a way to pass in vars as a argument input?

LWZ
  • 11,670
  • 22
  • 61
  • 79

1 Answers1

6

You can pass your cell array of variable names as a comma-separated list like so:

a = load('filename.mat', vars{:});
gnovice
  • 125,304
  • 15
  • 256
  • 359