How to extract a specific value within given range and row and column number which has a specific value.

1 Ansicht (letzte 30 Tage)
Just like the question, I want to extract row and column numbers.
example I want to find a closest value to 0.003 (there is no 0.003 in a matrix) in a n x 1 matrix.
How can I code it.

Antworten (1)

Nobel Mondal
Nobel Mondal am 2 Okt. 2015
>> randMatrix = (0.02*rand(5,1) - 0.01); % A random 5x1 matrix
>> [~, id] = min(abs(randMatrix - 0.003));
This would work for a vector. Please see Jan Simon's answer here to extend the logic for matrices.

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by