Reading variable from Tabulated data

1 view (last 30 days)
Abhishek Savita
Abhishek Savita on 21 Dec 2017
Commented: Abhishek Savita on 21 Dec 2017
Hi folks, I have file.mat in which variable arrange in tabulated as shown below
whos data
Name Size Bytes Class Attributes
data 326211x13 29364045 table
I have extract following variables from the table as
year = data{:,1}; %year 326211x1 2609688 double
lat = data{:,2}; %lat 326211x1 2609688 double
lon = data{:,3}; %lon 326211x1 2609688 double
OHC= data{:,7}; %OHC 326211x1 2609688 double
exp_seq_name = data{:,11}; %Experiment sequential number %326211x1 2609688 double
exp_name = data{:,12}; %exp_name 326211x1 327477 categorical
exp_all=categories(exp_name);
exp_all =
8×1 cell array
{'PB100_SG011BCT_SG011XBT'}
{'PB100_SG011BCT_SG021XBT'}
{'PB100_SG011BCT_SG040XBT'}
{'PB100_SG011BCT_SG033XBT'}
{'PB100_SG011BCT_SG060XBT'}
{'PB100_SG011BCT_SG054XBT'}
{'PB100_SG030BCT_SG021XBT'}
{'PB200_SG110BCT_SG121XBT'}
Where years are from (1950-2009)
Now i want to save a variable OHC in my new variable ohc_map_raw I have done in following way but every time I am getting same values for all experiment
[xx,yy] = meshgrid(unique(lon),unique(lat));
% xbt, year, lat, lon
ohc_map_raw= NaN(7,60,27,72);
ohc = xx*NaN;
time = 1950:1:2009;
%
for i = 1:size(exp_all,1)
dummy = find (exp_seq_name == i);
index_exp{i} = dummy;
% loop years
for j=1:length(time)
i_year = find(year(index_exp{i}) == time(j));
disp([num2str(i),' ',num2str(j),' ',num2str(time(j))])
% loop index
for k =1:length(i_year)
[ii,jj] = find( xx == lon(i_year(k)) & yy == lat(i_year(k)));
%disp([num2str(k),' ', num2str(length(i_year))])
ohc(ii,jj) = OHC(i_year(k));
end
ohc_map_raw(i,j,:,:) = ohc;
end
end
I have tried many times but unable to find out my mistake; Could some body help me on this;
Thanking in advance
  2 Comments
Image Analyst
Image Analyst on 21 Dec 2017
Edited: Image Analyst on 21 Dec 2017
You forgot to attach file.mat. It's often easier to answer people's questions if we can actually run their code. Give us everything we'd need to execute your code. Read this
And time and year are built-in functions so don't use those names for your variable names.
Abhishek Savita
Abhishek Savita on 21 Dec 2017
Sorry, I am trying to attach my file but it has size more than 5 MB. When i compressed it, the size is still same. how can i attach it. We have any other alternative to attach file more than 5 MB.

Sign in to comment.

Answers (0)

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!