Borrar filtros
Borrar filtros

Finding Maximum magnitude out of two arrays and output position with sign of that element

1 visualización (últimos 30 días)
clear all;
clc;
a=[ -1 -4 -7 -11 -14 -17;
-2 -5 -8 -12 -15 -18;
-3 -6 -9 -13 -16 -19;
0.100000000000000 0.400000000000000 0.700000000000000 0.110000000000000 0.140000000000000 0.170000000000000;
0.200000000000000 0.500000000000000 0.800000000000000 0.120000000000000 0.150000000000000 0.180000000000000;
0.300000000000000 0.600000000000000 0.900000000000000 0.130000000000000 0.160000000000000 0.190000000000000];
b =[ -0.300000000000000 -0.600000000000000 -0.900000000000000 -0.130000000000000 -0.160000000000000 -0.190000000000000;
-0.200000000000000 -0.500000000000000 -0.800000000000000 -0.120000000000000 -0.150000000000000 -0.180000000000000;
-0.100000000000000 -0.400000000000000 -0.700000000000000 -0.110000000000000 -0.140000000000000 -0.170000000000000;
3 6 9 13 16 19;
2 5 8 12 15 18;
1 4 7 11 14 17]
Output :
I need to find output maximum magnitude of each element from a and b combined and extract postion of that element either from a or b array. The output looks below :
c = [-1 -4 -7 -11 -14 -17;
-2 -5 -8 -12 -15 -18;
-3 -6 -9 -13 -16 -19;
3 6 9 13 16 19;
2 5 8 12 15 18;
1 4 7 11 14 17]
Any help would be appreciated.
Thanks in advance

Respuestas (1)

RAKESH KUMAR TOTA
RAKESH KUMAR TOTA el 15 de Dic. de 2021
for i = 1:6
for j = 1:6
if (sign(a1(i,j)) == -1 && sign(b1(i,j)) == -1)
c1(i,j) = min(a1(i,j), b1(i,j));
elseif (sign(a1(i,j)) == 1 && sign(b1(i,j)) == 1)
c1(i,j) = max(a1(i,j), b1(i,j));
else
if abs(a1(i,j))> abs(b1(i,j))
c1(i,j) = a1(i,j);
else
c1(i,j) = b1(i,j);
end
end
end
end
Assuming a array as a1 and b array as b1
Any efficient code that this code would be usefull.
Thanks in advance.

Categorías

Más información sobre Matched Filter and Ambiguity Function en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by