More efficient way of this code?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dimitrios
am 17 Mai 2014
Beantwortet: Image Analyst
am 18 Mai 2014
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?
0 Kommentare
Akzeptierte Antwort
Andrei Bobrov
am 17 Mai 2014
Bearbeitet: Andrei Bobrov
am 18 Mai 2014
fun1 = @(v,n)repmat(v,1,n)
0 Kommentare
Weitere Antworten (1)
Image Analyst
am 18 Mai 2014
% Setup/initialize.
x = [0 45 90]
z = 3 % or 2 or whatever you want.
% Now get your y output:
y = repmat(x, [1,z])
0 Kommentare
Siehe auch
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!