|
Hi!
I have 10 mat files which contains the variables of same name: stime, lon, lat, depth, u, v. Since they were derived from the same cruise, I am trying to combine them such that 'stime' contains the values of stime from 10 mat files, and 'lon' is from 'lon' of 10 mat files. The size of variables in different mat files is not the same,, but stime, lon, lat, depth are all 1xN, u and v are 64xN double.
I have looked for some Matlab-related web sites and generated the following code, but not successful, could anyone please help me about it? (I tried to use 'insertrow.m' from Matlab file-exchange). Thanks a lot!
% Get the list of files
D = dir('*.mat');
for k = 1:numel(D)
adcp = load(D(k).name);%put the mat into a structure
varname = fieldnames(adcp); % get the name of the variables in the structure
% depth,flat, flon, stime, u,v, u_ave, v_ave
m= numel(varname);% no. of variables
storedData = cell(1, numel(m));
for j=1:m
storedData{j} = NaN(size(adcp.(varname{j})));
storedData{j} = insertrows(cell2mat(storedData{j}),adcp.(varname{j}));
end
end
|