How can i extract the values in complex double array

22 visualizaciones (últimos 30 días)
feras
feras el 30 de Ag. de 2023
Comentada: Mathieu NOE el 30 de Ag. de 2023
I have the below complex double array, when i want to extract the fourth value and the ones which are above of the fourth one (like H(5) H(6) H(7) ....) Matlab says " All zero sparse: 1×1". so How can i extract them ?
H=
(1,1) -0.0181 - 0.0365i
(2,1) 0.2017 - 0.0552i
(3,1) 0.0795 - 0.0786i
(2,2) -0.0173 - 0.0370i
(3,2) 0.2023 - 0.0551i
(4,2) 0.0794 - 0.0785i
(3,3) -0.0166 - 0.0374i
(4,3) 0.2028 - 0.0551i
(5,3) 0.0793 - 0.0785i
(4,4) -0.0158 - 0.0378i
(5,4) 0.2034 - 0.0550i
(6,4) 0.0793 - 0.0784i
(5,5) -0.0151 - 0.0383i
(6,5) 0.2040 - 0.0549i
  2 comentarios
James Tursa
James Tursa el 30 de Ag. de 2023
Do you mean extract the fourth non-zero value? In memory order? Please post an example input and exact output you want.
Mathieu NOE
Mathieu NOE el 30 de Ag. de 2023
hello
according to your post H would be a 2D and not 1D arry so when you say the fourth and above index is fine for a 1D array but I don't know what you need to extract for a 2D array
H(1,1) = -0.0181 - 0.0365i;
H(2,1) = 0.2017 - 0.0552i;
H(3,1) = 0.0795 - 0.0786i;
H(2,2) = -0.0173 - 0.0370i;
H(3,2) = 0.2023 - 0.0551i;
H(4,2) = 0.0794 - 0.0785i;
H(3,3) = -0.0166 - 0.0374i;
H(4,3) = 0.2028 - 0.0551i;
H(5,3) = 0.0793 - 0.0785i;
H(4,4) = -0.0158 - 0.0378i;
H(5,4) = 0.2034 - 0.0550i;
H(6,4) = 0.0793 - 0.0784i;
H(5,5) = -0.0151 - 0.0383i;
H(6,5) = 0.2040 - 0.0549i;
imagesc(abs(H));colorbar('vert')

Iniciar sesión para comentar.

Respuestas (1)

MYBLOG
MYBLOG el 30 de Ag. de 2023
You can achieve this using logical indexing and comparison of the magnitudes of the complex values. Here's how you can extract the fourth value and the values above it in MATLAB:
% Given complex array H
H = [
-0.0181 - 0.0365i
0.2017 - 0.0552i
0.0795 - 0.0786i
-0.0173 - 0.0370i
0.2023 - 0.0551i
0.0794 - 0.0785i
-0.0166 - 0.0374i
0.2028 - 0.0551i
0.0793 - 0.0785i
-0.0158 - 0.0378i
0.2034 - 0.0550i
0.0793 - 0.0784i
-0.0151 - 0.0383i
0.2040 - 0.0549i
];
% Extract the fourth value
fourth_value = H(4);
% Find the indices of values above the fourth value
above_fourth_indices = abs(H) > abs(fourth_value);
% Extract the values above the fourth value
values_above_fourth = H(above_fourth_indices);
% Display the results
disp('Fourth Value:');
disp(fourth_value);
disp('Values Above Fourth Value:');
disp(values_above_fourth);

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by