Max values in certain columns with corresponding row value?
显示 更早的评论
I have a [4x12] matrix where column 1 consists of times 0-24 (hours) at 2 hour increments, and columns 2-4 were loaded from a file that my professor gave me.
The question asks me to find the max and min in each column and the corresponding time that that max and min occur.
Here’s my code so far
times=[0:2:24]; times=times(:) load thermocouple.dat thermocouple_data=[times,thermocouple] round(thermocouple_data,1] thermocouple_max=max(thermocouple_data) thermocouple_min=min(thermocouple_data) [thermocouple_max,k_max]=max(thermocouple_data) [thermocouple_min,k_min]=min(thermocouple_data)
This gives me the max and min and number locations of each column, but I need to know what times those values occur at.
For example, I know that the max of column 2 is 87.1. That happened at 6 hours (row 4). How do I get MATLAB to show me that it happens at 6 hours, not row (location) 4?
回答(1 个)
Star Strider
2018-2-11
‘How do I get MATLAB to show me that it happens at 6 hours, not row (location) 4?’
Since ‘row (location) 4’ is an index:
times=[0:2:24];
Out = times(4)
Out =
6
This should get you started. I leave the coding with respect to your matrix to you.
类别
在 帮助中心 和 File Exchange 中查找有关 Operators and Elementary Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!