Mean and Median of Values in a matrix
2 次查看(过去 30 天)
显示 更早的评论
I want to take the mean and median of the mean and median of four columns and then store those values in a separate file to plot the graph later. I have 30,000 rows, with four columns as below: The below is an example of the data points. The first column has a different range of flow rates. I want to take the mean and median of all columns, considering that this average will be based on the set range of 1st column, for example, range 800-900, 900-1000, 1000-11000, and so.
The results will be stored in some other file so that I can make the graph. load.
Data file example below:
Flow Rate Entrance Pressure Exit Pressure Pressure Difference
820 7.52 6.5 1.02
820 7.49 6.55 .94
820 7.51 6.52 0.99
820 7.57 6.58 0.99
820 7.58 6.58 1
819 7.54 6.59 0.95
907 9.27 7.8 1.47
915 9.3 7.78 1.52
918 9.35 7.91 1.44
917 9.46 7.97 1.49
1011 11.2 9.44 1.76
1005 11.38 9.58 1.8
1005 11.32 9.54 1.78
1005 11.39 9.49 1.9
1005 11.32 9.51 1.81
1005 11.26 9.44 1.82
Any help is appreciated.
Thanks
3 个评论
Dyuman Joshi
2022-5-14
I'm assuming you want to do seperate matrices for mean and median values? And that you want to use for loops as well?
回答(3 个)
Dyuman Joshi
2022-5-14
I am giving you an example for one variable.
meanvalue=[];
medianvalue=[];
for i=800:100:lastvalue
y=flowrate(flowrate>=i&flowrate<(i+100));
meanvalue=[meanvalue mean(y)];
medianvalue=[medianvalue median(y)];
end
Are the groups in the same range here? i.e 800-900 group in flowrate corresponds to 7-8 group in extrance pressure, 6-7 in exit pressure and 0.9-1 in pressure difference, for all ranges?
If they are not, the output matrix you want (with 4 columns) will not be possible.
5 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Preprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!