How to compare values in two vectors and modify a new vector based on that results?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hassan garni
am 20 Jan. 2018
Bearbeitet: James Tursa
am 20 Jan. 2018
Hello,
I am comparing two vector angles t1 and t2, and if the cell in the t1>=t2 then the azmiuth angle t3 = Az1 if not t3 = Az2. This is should be for every element in the vector. I tried "if-else" but always giving me the t3=Az2.
Azd1;
Azd2 ;
t1;
t2;
if t1>= t2;
Azd = Azd1
else Azd = Azd2
end
I appreciate if somebody can help.
Thank you.
Hassan
0 Kommentare
Akzeptierte Antwort
James Tursa
am 20 Jan. 2018
Bearbeitet: James Tursa
am 20 Jan. 2018
If Azd1 and Azd2 are vectors, then
Azd = Azd2;
x = (t1>=t2);
Azd(x) = Azd1(x);
If Azd1 and Azd2 are scalars, then
Azd = zeros(size(t1));
x = (t1>=t2);
Azd(x) = Azd1;
Azd(~x) = Azd2;
0 Kommentare
Weitere Antworten (1)
Star Strider
am 20 Jan. 2018
Bearbeitet: Star Strider
am 20 Jan. 2018
Try this anonymous function:
va = @(t1,t2,Az1,Az2) (t1 >= t2).*Az1 + (t1 < t2).*Az2;
Az1 = 10;
Az2 = 20;
Result1 = va(1,2,Az1,Az2)
Result2 = va(2,1,Az1,Az2)
Result1 =
20
Result2 =
10
0 Kommentare
Siehe auch
Kategorien
Mehr zu Discrete Multiresolution Analysis 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!