フィルターのクリア

Calling same function repeatedly for different set of input parameters,with out using for loop.

3 ビュー (過去 30 日間)
Hi... x= 1 2
2 3
4 5
x is a 3x2 matrix
z1 = distance(x1,c1);
z2 = distance(x2,c2);
z3 = distance(x3,c3);
x1 - first row of 'x' ;
x2-second row of 'x';
x3-third row of 'x'.
similarly like 'x','c' is also 3x2 matrix. where c1-first row of 'c';similarly 'c2' and 'c3'.
'distance' is a function which takes two inputs,and compute the the distance between the two inputs and return it.
i know that above can be implemented by using for-loop but is there any better way,instead of looping,so that i get 'z' as a 3x1 matrix.
z(1,1)=z1;
z(2,1)=z2;
z(3,1)=z3;
Regards,
Chandradhar Savanth

採用された回答

Walter Roberson
Walter Roberson 2013 年 9 月 18 日
z = arrayfun( @distance, x, c );

その他の回答 (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