Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Sums elements of a row
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello everyone!
I have the following problem (I bring an example):
I am in this initial situation:
Company worker1 worker2 worker3 worker4 worker5
AAAAA M F F F M
BBBBB F F M
CCCC M M F M
DDDDD F M
I would like to get the sum of M and F for each line and have this as the final result:
Company worker1 worker2 worker3 worker4 worker5 SumM SumF
AAAAA M F F F M 2 3
BBBBB F F M 1 2
CCCC M M F M 3 1
DDDDD F F 0 2
Finally, save it all in excel
I attach a piece of code that I wrote (I don't know if it is right or useful to achieve the required result)
clear all;
clc;
load('DBTot.mat');
%%
n=size(DBTot,1);
m=size(DBTot,2);
DBGender=DBTot(:,[1,(7:4:m)]); % selec only the gender
DBGender=table2cell(DBGender);
n1=size(DBGender,1);
m1=size(DBGender,1);
clear DBTot
strDBGender=string(DBGender);
Thank you all!
3 comentarios
Walter Roberson
el 23 de Feb. de 2020
DBGender = DBTot{:,7:4:m};
Looks more plausible to me. It would be odd to have gender as the first column.
By the way, you should be improving the logic to count all the other genders as well as M and F.
Respuestas (0)
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!