One command to extract all the data

3 views (last 30 days)
Mac
Mac on 22 Dec 2021
Commented: Mac on 23 Dec 2021
I have data that looks like the image above. Could anyone please help me what command to use to extract all the data? I did it manually using the code below. But, I have another data that is up to val(:,:,365), so any help is greatly appreciated.
sla=ncread('cmems_obs-sl_glo_phy-ssh_my_allsat-l4-duacs-0.25deg_P1M-m_1639987960602.nc','sla');
A1=sla(:,:,1)';
A2=sla(:,:,2)';
A3=sla(:,:,3)';
A4=sla(:,:,4)';
A5=sla(:,:,5)';
A6=sla(:,:,6)';
A7=sla(:,:,7)';
A8=sla(:,:,8)';
A9=sla(:,:,9)';
A10=sla(:,:,10)';
A11=sla(:,:,11)';
A12=sla(:,:,12)';
slaData=vertcat(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12);

Accepted Answer

DGM
DGM on 22 Dec 2021
Edited: DGM on 22 Dec 2021
Just permute the array dimensions.
sla = cat(3,(1:10).',(11:20).',(21:30).',(31:40).'); % smaller example array
size(sla) % 4 columns arranged on dim3
ans = 1×3
10 1 4
% permute
sla = permute(sla,[3 1 2])
sla = 4×10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
  1 Comment
Mac
Mac on 23 Dec 2021
Wow. That's amazing. Thank you very DGM. Appreciate it a lot.

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB 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!