Max values in certain columns with corresponding row value?
Mostrar comentarios más antiguos
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?
Respuestas (1)
Star Strider
el 11 de Feb. de 2018
‘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.
Categorías
Más información sobre Operators and Elementary Operations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!