How do I find the value for which x% of the array is covered?

1 回表示 (過去 30 日間)
Lieke Pullen
Lieke Pullen 2022 年 1 月 19 日
編集済み: Prahlad Gowtham Katte 2022 年 1 月 25 日
Hi all,
I have a 3D array (attached), where I calculated the dose per voxel. Now, I want to find the minimum dose for which 20% of the array is covered (exluding zeros). I've tried the following:
D20_VSV=sort(D_tumorVSV(:),'descend');
result=D20_VSV(1:ceil(length(D20_VSV)*0.9));
This is a simple code (via this question), but doesn't seem to give the wanted result. How should I do this? Thank you in advance!

採用された回答

Prahlad Gowtham Katte
Prahlad Gowtham Katte 2022 年 1 月 25 日
編集済み: Prahlad Gowtham Katte 2022 年 1 月 25 日
Hi
My understanding of the question is that you want to sort a 3-dimensional array and you want to extract the minimum for which 20% of the array is covered excluding zeroes.
The following code snippet can help with the issue
x = C_holllowtumor; %A random 3-dimensional array
y = sort(x(:),'ascend'); % Sorting the array in ascending order
y = nonzero(y); % Extracting the non-zero elements
Result = y(1:ceil(length(y)*0.2)); % Getting the 20% elements
%Result(end) --this would give a single element from the Result.
To know more about sorting and excluding a particular element please refer to the following links.
Hope this helps
Thanks

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by