From: Pragya on
Hi,

I want to load two mat files simultaneously into the workspace. These mat files contain a 50X13 array each. I want to subtract the value from one array in a mat file from the corresponding array element in another and store the data in another mat file. On using load A.mat;
load B,mat;
the second one overwrites the first.

On using :
matdata(1)=load('A.mat');
matdata(2)=load('B.mat');

a 1X2 structure->matdata is formed in the workspace but now how should i compare the successive elements of the 2 arrays in the structure?
matdata(1)(i,j)-matdata(2)(i,j) does not work:(
From: Steven Lord on

"Pragya " <pragoel12(a)yahoo.com> wrote in message
news:i1or0b$ico$1(a)fred.mathworks.com...
> Hi,
>
> I want to load two mat files simultaneously into the workspace. These mat
> files contain a 50X13 array each. I want to subtract the value from one
> array in a mat file from the corresponding array element in another and
> store the data in another mat file. On using load A.mat; load B,mat;
> the second one overwrites the first.
>
> On using :
> matdata(1)=load('A.mat');

This makes matdata a _struct array_, with one field for each variable that
was stored in A.mat.

> matdata(2)=load('B.mat');

> a 1X2 structure->matdata is formed in the workspace but now how should i
> compare the successive elements of the 2 arrays in the structure?
> matdata(1)(i,j)-matdata(2)(i,j) does not work:(

No, it doesn't -- you need to use the field name to refer to the contents of
the field in the matdata struct. For instance, if both A.mat and B.mat
contained a variable named x, you'd use:

matdata(1).x - matdata(2).x

to subtract B's x from A's x.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com


 | 
Pages: 1
Prev: Using FFTW in mex file
Next: input