Find values between 50th to 75th percentile.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Pritha Pande
el 30 de Oct. de 2017
Comentada: Sachindra Dhanapala Arachchige
el 6 de Mayo de 2018
I have 80*80 matrix, from which I want to extract values which lie under 50th to 75th percentile. I want to write a code such that the new matrix now formed have data which lie under 50th to 75th percentile and other values will be shown as NaN.Something like this:
for i=1:80;
for j=1:80;
if (My_matrix(i,j)<=prctile(My_matrix(i,j),25)&(My_matrix(i,j),50)=xx;
else My_matrix(i,j)==NaN
end;
end;
end;
Where, My_matrix is 2d matrix of 80*80 size. Please correct the code i have written, or tell how i can find the values which lies between 25th to 50th percentile
0 comentarios
Respuesta aceptada
Andrei Bobrov
el 30 de Oct. de 2017
Editada: Andrei Bobrov
el 30 de Oct. de 2017
t = prctile(My_matrix,25) > My_matrix | prctile(My_matrix,75) < My_matrix;
out = My_matrix;
out(t) = nan;
2 comentarios
Pritha Pande
el 30 de Oct. de 2017
Editada: Pritha Pande
el 30 de Oct. de 2017
Sachindra Dhanapala Arachchige
el 6 de Mayo de 2018
As I understand Andrei's code outputs a logical matrix (0 and 1) which satisfies the condition given in the first line of his code. By multiplying the 'My_matrix' with 't' one could get the values within 'My_matrix' which satisfy the above condition. Try the following and see. B = My_matrix.*t;
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!