フィルターのクリア

More efficient way of this code?

1 回表示 (過去 30 日間)
Dimitrios
Dimitrios 2014 年 5 月 17 日
回答済み: Image Analyst 2014 年 5 月 18 日
Lets say that i have a function : y=fun(x,z) that do the following calculations :
ex1:
fun([0 45 90],2) , y=[0 45 90 0 45 90]
ex2:
fun([0 45 90],3) , y=[0 45 90 0 45 90 0 45 90]
My code is the following :
Initialx=x;
for ii = 2:z
x=[x Initialx];
end
Is there a more efficient way to do it ? a vectorized or gennerally another way to impliment it?

採用された回答

Andrei Bobrov
Andrei Bobrov 2014 年 5 月 17 日
編集済み: Andrei Bobrov 2014 年 5 月 18 日
fun1 = @(v,n)repmat(v,1,n)

その他の回答 (1 件)

Image Analyst
Image Analyst 2014 年 5 月 18 日
% Setup/initialize.
x = [0 45 90]
z = 3 % or 2 or whatever you want.
% Now get your y output:
y = repmat(x, [1,z])

カテゴリ

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