How is the average and normalization of each column in the table using "for" loop?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a table with 50x10. In the table, first column is Genes and the second column will be reference column for normalization. Other 8 column will divide reference column. Afterward, this table will be normalized and each column will be averaged after normalization. Therefore there will be one row and 8 columns. How can I do this process in a table. Is it necessary to convert this table to a matrix or dataset, or can we solve it with a simle loop?
I m trying this code for table:
%import data
data = readtable("data.xlsx", "UseExcel", false);
%I coverted table to matrix form by deleting first row
for i = 2:10
res(:,i-1) = data(:,i)./data(:,1);
res_m = mean(res);
end
Bu code is not working as I want and I want to try this with table or dataset form
% Genes gsm335244 gsm335245 gsm335246
% A1CF 1,194 0,848 0,905
% A2M 0,325 6,301 0,607
% A4GALT 1,048 0,592 1,964
2 commentaires
KALYAN ACHARJYA
le 18 Nov 2019
Modifié(e) : KALYAN ACHARJYA
le 18 Nov 2019
In the RHS, what does it mean?
res(:,i-1)=data(:,i)./data(:,1); % RHS > Same Parameters
Please attach data file
Réponses (1)
Srijith Kasaragod
le 4 Août 2021
Modifié(e) : Srijith Kasaragod
le 5 Août 2021
From my understanding you have a 50x10 table, columns 3 to 10 must be divided with corresponding elements from column 2, followed by taking the mean of those eight columns. The required output can be obtained by simple manipulation of the table. Following code implements the steps:
%reading the table
data= readtable('data.xlsx');
%perform normalization and take mean of columns
data{:,3:end}=data{:,3:end}./data{:,2};
data= mean(data{:,3:end})
Final result is a table of size 1x8 which contains mean of columns 3 to 10.
0 commentaires
Voir également
Catégories
En savoir plus sur Tables dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!