Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6643685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:04:44+00:00 2026-05-26T00:04:44+00:00

very basic question: How can I find the highest or lowest value in a

  • 0

very basic question: How can I find the highest or lowest value in a random matrix.
I know there is a possibility to say:

a = find(A>0.5)

but what I’m looking for would be more like this:

A = rand(5,5)
A = 
0.9388    0.9498    0.6059    0.7447    0.2835
0.6338    0.0104    0.5179    0.8738    0.0586
0.9297    0.1678    0.9429    0.9641    0.8210
0.0629    0.7553    0.7412    0.9819    0.1795
0.3069    0.8338    0.7011    0.9186    0.0349

% find highest (or lowest) value

ans = A(19)%for the highest or A(7) %for the lowest value in this case
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:04:45+00:00Added an answer on May 26, 2026 at 12:04 am

    Have a look at the min() and max() functions. They can return both the highest/lowest value, and its index:

    [B,I]=min(A(:)); %# note I fixed a bug on this line!
    

    returns I=7 and B=A(7)=A(2,2). The expression A(:) tells MATLAB to treat A as a 1D array for now, so even though A is 5×5, it returns the linear index 7.

    If you need the 2D coordinates, i.e. the “2,2” in B=A(7)=A(2,2), you can use [I,J] = ind2sub(size(A),I) which returns I=2,J=2, see here.

    Update
    If you need all the entries’ indices which reach the minimum value, you can use find:

    I = find(A==min(A(:));
    

    I is now a vector of all of them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question sounds very basic. But I can't find it using Google.
This probably is a very very basic question but i can't seem to find
Sorry for the very basic question, but I can't find on google how to
Very basic question - but I couldn't find an answer. I have got a
I know this maybe a very basic question but I'm having a bit of
Very basic question, but I have an error in my code that can only
Disclaimer: I understand the question is very basic, but I could not find the
This is a very basic MySQL question but I could not find an answer.
Very basic question: how do I write a short literal in C++? I know
Very basic question - how to get one value from a generator in Python?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.