MATLAB: How to arrange a column in a concatenated Matrix

MATLABsummatrix

Hello Everyone,
I'm having hard time arrange the last Column which represents a the total nymber of each row in the following matrix. May you kindly highlight my mistake?
Much Obliged:
Title = ["Reported Country case","No . Deaths","Active case Total","Recovered","Total Cases"]
Countryname = ["Spain";"China";"Germany";"Iran";"France";"UK";"USA";"Italy"]
CasesNum = [24543,77112,137984;4633,599,77642;6623,29486,126900;6091,13237,76318;24376,93326,49476;26771,144138,0;63871,875696,155737;27967,101551,75945];
Totalsumcolum = sum(CasesNum',1)
CasesNumT = [CasesNum,Totalsumcolum']
TotalAppended = [Countryname,CasesNum,Totalsumcolum']
Totalsumrow = sum(CasesNumT,1);

Best Answer

Try this:
Title = ["Reported Country case","No . Deaths","Active case Total","Recovered","Total Cases"]
Countryname = ["Spain";"China";"Germany";"Iran";"France";"UK";"USA";"Italy"]
CasesNum = [24543,77112,137984;4633,599,77642;6623,29486,126900;6091,13237,76318;24376,93326,49476;26771,144138,0;63871,875696,155737;27967,101551,75945];
Totalsumcolum = sum(CasesNum',1)
CasesNumT = [CasesNum,Totalsumcolum']
TotalAppended = [Countryname,CasesNum,Totalsumcolum']
Totalsumrow = sum(CasesNumT,1);
t = table(Countryname, CasesNumT(:, 1), CasesNumT(:, 2), CasesNumT(:, 3), CasesNumT(:, 4), 'VariableNames', Title)
You'll get a table:
t =
8×5 table
Reported Country case No . Deaths Active case Total Recovered Total Cases
_____________________ ___________ _________________ _________ ___________
"Spain" 24543 77112 137984 239639
"China" 4633 599 77642 82874
"Germany" 6623 29486 126900 163009
"Iran" 6091 13237 76318 95646
"France" 24376 93326 49476 167178
"UK" 26771 144138 0 170909
"USA" 63871 875696 155737 1095304
"Italy" 27967 101551 75945 205463