double to table, create new tabel and add data to existing table with different properties

8 views (last 30 days)
Hello,
I have a Matlab table for which I carry out many individual calculations as can be seen in the code. the results are columns and tables in double format. I'm having a hard time putting the data back together in a table. I would like a separate table for BHQ, HQextrem, HQ5000 and HQ 10000 with the following data
  • colums 1:6; PP_D colums 1:6; with column names OID, FKM, Lage, x, y, z
  • colums 7; ...MWH name: Maximalewasserhöhe
  • colums 8; ...MWA name:Maximaler Wasseranstieg
  • colums 9; ...MWR name: Maximaler Wasserrückgang
  • colums 10;...FD name: Maximale Überflutungsdauer
  • colums 11: 152; ...WH names: WH Time 0:142
  • colums 153: 295: ... WA names WA Time 0:142
Thanks for your help
here the code and the data:
%% Bearbeitung Punkte
clc
clear all
clear workspace
load ('PP_D.mat')
PP_D_new = removevars(PP_D, {'OID_','FKM','Lage'});
PP_D_string = table2array(PP_D_new);
PP_D_string(PP_D_string==0)=nan
%% Wasserhöhen
for i=1:151
PP_D_Wasserhoehe (i,:)= PP_D_string([i],[4:513])- PP_D_string(i,3);
end
% PP_D_Wasserhoehe=str2double(PP_D_Wasserhoehe);
D_BHQ_WH= PP_D_Wasserhoehe([1:151],[1:83])
D_HQextrem_WH= PP_D_Wasserhoehe([1:151],[84:225])
D_HQ5000_WH= PP_D_Wasserhoehe([1:151],[226:367])
D_HQ10000_WH= PP_D_Wasserhoehe([1:151],[368:509])
%Maximale Wasserhöhen
for i=1:151
D_HQ10000_MWH (i,1)= max(D_HQ10000_WH(i,[1:142]));
D_HQ5000_MWH (i,1)= max(D_HQ5000_WH(i,[1:142]));
D_HQextrem_MWH (i,1)= max(D_HQextrem_WH(i,[1:142]));
D_BHQ_MWH (i,1)= max(D_BHQ_WH(i,[1:83]));
end
%% Anstieg pro Zeitschritt [m/h]
PP_D_Wasserhoehe(isnan(PP_D_Wasserhoehe))=0;
for i=2:510
PP_D_Wasserhoehe_Wasseranstieg(:,i)= PP_D_Wasserhoehe([1:151],i)- PP_D_Wasserhoehe([1:151],i-1);
end
D_BHQ_WA= PP_D_Wasserhoehe_Wasseranstieg([1:151],[1:83])
D_HQextrem_WA= PP_D_Wasserhoehe_Wasseranstieg([1:151],[84:225])
D_HQ5000_WA= PP_D_Wasserhoehe_Wasseranstieg([1:151],[226:367])
D_HQ10000_WA= PP_D_Wasserhoehe_Wasseranstieg([1:151],[368:509])
%Maximaler Wasseranstieg
for i=1:151
D_HQ10000_MWA (i,1)= max(D_HQ10000_WA(i,[1:142]));
D_HQ5000_MWA (i,1)= max(D_HQ5000_WA(i,[1:142]));
D_HQextrem_MWA (i,1)= max(D_HQextrem_WA(i,[1:142]));
D_BHQ_MWA (i,1)= max(D_BHQ_WA(i,[1:83]));
end
%Maximaler Wasserrückgang
for i=1:151
D_HQ10000_MWR (i,1)= min(D_HQ10000_WA(i,[1:142]));
D_HQ5000_MWR (i,1)= min(D_HQ5000_WA(i,[1:142]));
D_HQextrem_MWR (i,1)= min(D_HQextrem_WA(i,[1:142]));
D_BHQ_MWR (i,1)= min(D_BHQ_WA(i,[1:83]));
end
%% Überflutungsdauer
PP_D_Wasserhoehe(isnan(PP_D_Wasserhoehe))=0;
D_BHQ_x= PP_D_Wasserhoehe([1:151],[1:83]);
D_HQextrem_x= PP_D_Wasserhoehe([1:151],[84:225]);
D_HQ5000_x= PP_D_Wasserhoehe([1:151],[226:367]);
D_HQ10000_x= PP_D_Wasserhoehe([1:151],[368:509]);
for i=1:151
D_HQ10000_FD (i,1)= nnz(D_HQ10000_x(i,[1:142]));
D_HQ5000_FD (i,1)= nnz(D_HQ5000_x(i,[1:142]));
D_HQextrem_FD (i,1)= nnz(D_HQextrem_x(i,[1:142]));
D_BHQ_FD (i,1)= nnz(D_BHQ_x(i,[1:83]));
end

Answers (0)

Community Treasure Hunt

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

Start Hunting!