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 日

0 投票

‘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 ExchangeResizing and Reshaping Matrices についてさらに検索

質問済み:

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