How can i process CTD data with a 'for' cycle?

10 views (last 30 days)
Hello, i will be short. 1.- I have a 717x3 matrix with depth data in the first, Temperature in second and Salinity in third columns, respectively.
2.- Maximun depth is 475 meters, but i have 717 values of each column, so i want to have the mean of the data for every meter in order to have a 475x3 matrix, i mean, from 0 to 1 meter, the respective mean value of temperature and salinity, the same from 1 to 2 meters, etc.
3.- To explain this a little bit more, i'd like to present a little matrix as an example with the code i have written.
Depth - Temperature - Salinity
0.927000000000000 26.7092000000000 34.3817000000000
0.927000000000000 26.7092000000000 34.3751000000000
0.927000000000000 26.7060000000000 34.4259000000000
0.927000000000000 26.7061000000000 34.4194000000000
1.01800000000000 26.7048000000000 34.2680000000000
1.01800000000000 26.7068000000000 34.4142000000000
1.01800000000000 26.7068000000000 34.4109000000000
2.91400000000000 26.7044000000000 34.4622000000000
3.00400000000000 26.7044000000000 34.4655000000000
4.26800000000000 26.7067000000000 34.4647000000000
4.90000000000000 26.7067000000000 34.4634000000000
CODE
b=0;
o=0;
l=1;
clear vpm
for k=1:length(est_1(:,2))
if floor(est_1(k,2))==b
vp(l,1:2)=est_1(k,3:4);
l=l+1;
elseif floor(est_1(k+1,2))~=b
o=o+1;
if l==1;
vp(l,1:2)=est_1(k,3:4);
vpm(o,1)=o;
vpm(o,2)=vp(l,1);
vpm(o,3)=vp(l,2);
b=b+1;
% l=1;
clear vp
else
%l=l+1;
vp(l,1:2)=est_1(k,3:4);
vpm(o,1)=o;
vpm(o,2)=mean(vp(:,1),1);
vpm(o,3)=mean(vp(:,2),1);
b=b+1;
l=1;
clear vp
end
end
end

Answers (0)

Categories

Find more on Oceanography and Hydrology 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!