Suppose I have 1000x1 matrix and my data is from (50,60) and then from (160,170) and so on (i.e randomly distributed), What I want is to find maximum out of this 50 to 60 location and then maximum from 160 to 170 location and so on. How to find this ?

3 commentaires

Walter Roberson
Walter Roberson le 22 Juin 2019
Are those data ranges or are they index locations ?
If they are index locations, are the locations known ahead of time?
Rohan  Mehta
Rohan Mehta le 22 Juin 2019
index locations
Rohan  Mehta
Rohan Mehta le 22 Juin 2019
yes these locations are stored in another matrix

Connectez-vous pour commenter.

 Réponse acceptée

KALYAN ACHARJYA
KALYAN ACHARJYA le 22 Juin 2019
Modifié(e) : KALYAN ACHARJYA le 22 Juin 2019

0 votes

Suppose mat is 1000x1 matrix
%this will give the maximum value within the matrix uptp 50 rows and 60 colm
mat1=mat(1:50,1:60);
max1=max(mat1(:));
You can do the same form other also
mat2=mat(1:160,1:170);
max2=max(mat2(:));
Is this you are looking for?

4 commentaires

Rohan  Mehta
Rohan Mehta le 22 Juin 2019
Hi Thanks for help
But what I want is that my data locations are stored in another matrix named K which has 5 variables (Say 50,250,550,750,950) that contain location of my data in matrix A, So I want to find maximum out of the 40 to 60 locations and then from 240,260 and then from 540 to 560 and so on...
KALYAN ACHARJYA
KALYAN ACHARJYA le 22 Juin 2019
Modifié(e) : KALYAN ACHARJYA le 24 Juin 2019
to read the index of maximum elements do the following
max1=max(a(:));
[r1,c1]=find(a==max1)
As your comment is confusing, though the question seems easy, thats why I have provided the how to find maimum from a matrix and read the index of maximum elements. Rest you can store the indeces as you want.
Rohan  Mehta
Rohan Mehta le 24 Juin 2019
Hello Sir this piece of code almost solved my problem As I have found all the maximums but one doubt is how to assign the location's of these maximum to another matrix ?
how to assign the location's of these maximum to another matrix?
The second part of comment is not clear for me.
Are you looking for this one?
mat_other(r1,c1)
%..........^ index values from first matrix having maximum value

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by