I have a following matrix
aa =
245.2708 2.6912 21.0000
245.2778 2.3969 21.0000
245.2847 4.9097 21.0000
245.2917 5.5113 21.0000
245.2986 6.9260 21.0000
245.3056 20.5392 21.0000
245.3403 40.6676 21.0000
245.3472 28.8638 21.0000
245.3542 45.3048 21.0000
245.3611 47.9512 21.0000
245.3681 NaN NaN
245.3889 15.3675 21.0000
245.3958 15.0250 21.0000
Time =aa(:,1);
x =aa(:,2);
y =aa(:,3);
Now I need to create a new vector 'z' and it should contain all values of 'x' when 'x' is greater than 'y' and in case 'x' is smaller than 'y' then fill 'z' with 'y'. Out put for 'z' look like as follow.
z =
21
21
21
21
21
21
40.6676
28.8638
45.3048
47.9512
NaN
21
21
z = max(x, y)
Be careful with NaN
, because it is neither lower, nor greater nor equal to any number. So, if, for example, x
has a NaN
on a position where y
doesn't, then the value in x
will always be chosen.