How to avoid for loop, when using ecdf for a matrix?

1 回表示 (過去 30 日間)
ARGY B
ARGY B 2019 年 8 月 21 日
コメント済み: ARGY B 2019 年 8 月 21 日
Is there a smarter way to create a matrix fx and a matrix x without using the for loop?
for i=1:4
[fx(:,i) x(:,i)]= ecdf(A(index(i),:));
end
A : a matrix (size 100000x10000)
and index is
index =
7307
21917
40179
58441
I just want the four ecdf results for only the four rows I chose (using the variable named index).
For example the following does not work:
[fx x]= ecdf(A(index,:));

採用された回答

the cyclist
the cyclist 2019 年 8 月 21 日
編集済み: the cyclist 2019 年 8 月 21 日
No. Inside the code for ecdf.m, you can see the line that explicitly creates an error message if the input is not a vector. I won't post the actual code, but you can do
type ecdf.m
to see for yourself. (The line is near the top of the file, and commented.)
If you wanted to, I suppose you could create your own "parallelized" version of ecdf (by copying and editing ecdf), in which you loop through your matrix internally within your new function. But that has its own inelegancies.
  1 件のコメント
ARGY B
ARGY B 2019 年 8 月 21 日
You are right. I checked it out.
Thank you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by