필터 지우기
필터 지우기

How can i extract the values in complex double array

조회 수: 14 (최근 30일)
feras
feras 2023년 8월 30일
댓글: Mathieu NOE 2023년 8월 30일
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
James Tursa
James Tursa 2023년 8월 30일
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 2023년 8월 30일
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')

댓글을 달려면 로그인하십시오.

답변 (1개)

MYBLOG
MYBLOG 2023년 8월 30일
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);

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by