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
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.
See the documentation on Matrix Indexing (link) for details.

카테고리

도움말 센터File Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

질문:

2018년 2월 11일

답변:

2018년 2월 11일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by