finding the mean/average of the smallest values in a row

1 visualización (últimos 30 días)
Ach
Ach el 25 de Feb. de 2018
Respondida: Mann Baidi el 6 de Mayo de 2024
hi , i have a row and i want to find the average of the smallest values and the position of this minimum.

Respuestas (1)

Mann Baidi
Mann Baidi el 6 de Mayo de 2024
Hi @Ach,
For finding the minimum values for each row in a matrix, you can use the "min" function in MATLAB.
You can use the min function for your requirement as follows:
rng default % for reproducibility
A = rand(5,10)
A = 5x10
0.8147 0.0975 0.1576 0.1419 0.6557 0.7577 0.7060 0.8235 0.4387 0.4898 0.9058 0.2785 0.9706 0.4218 0.0357 0.7431 0.0318 0.6948 0.3816 0.4456 0.1270 0.5469 0.9572 0.9157 0.8491 0.3922 0.2769 0.3171 0.7655 0.6463 0.9134 0.9575 0.4854 0.7922 0.9340 0.6555 0.0462 0.9502 0.7952 0.7094 0.6324 0.9649 0.8003 0.9595 0.6787 0.1712 0.0971 0.0344 0.1869 0.7547
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
% use min function to get smallest element from each row.
[min_numbers,idx] = min(A,[],2) % idx refers to the postition of the minimum number in the row
min_numbers = 5x1
0.0975 0.0318 0.1270 0.0462 0.0344
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
idx = 5x1
2 7 1 7 8
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
% use mean function
result = mean(min_numbers)
result = 0.0674
You can refer to the following example in the 'min' function documentation
I hope this helps resolve the query.

Categorías

Más información sobre Linear Algebra en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by