-2

how to save matrix with extension .mat for example I've this matrix :

x = round (100*rand(4,4))

I want to save x matrix in file x.mat then load it which can access element of this matrix, I tried by loading x.matrix but it was gave me struct 1X1

sarot
  • 49
  • 1
  • 1
  • 4

1 Answers1

0

save 'x.mat'; or save x; command will do the saving

load 'x.mat'; or load x; will get back the matrix x in your workspace

data_cell = struct2cell(load('x.mat'));
data = data_cell{1};

or if you are sure only one matrix in x.mat:

data = struct2array(load('x.mat'));
Ray
  • 2,472
  • 18
  • 22