Saving the average in each iteration of a for loop
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello!
I have some data and I am trying to get a mean of 4 specific numbers for each row in an excel sheet. Some of my data looks like the below:
I want to save each mean for each row in a matrix "avgthic". My current code looks like this:
avgthic=[]
for i = 1:height(id)
avgthic=avgthic+1;
edges= [athic(i,:), pthic(i,:), mthic(i,:), lthic(i,:)];
edgematrix=table2array(edges);
avgthic=mean(edgematrix, 'omitnan');
%This is averaging only the last row, not row 1, 2, and so on....
end
the "height(id)" is the height of column with the name of each element each measurement comes from, so I should have the same number of rows as I have id's. How would I get matlab to save each average for each row?
0 comentarios
Respuestas (1)
KSSV
el 28 de Jul. de 2022
T = readtable(myfile) ;
data = table2array(T) ;
avgthic = mean(data,2,'omitnan')
0 comentarios
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!