how can i separate real numbers?

hi guys
I have this matrix for example: A=[11.3 , 10+5i , 32 , 50+48i , 9 , 21+15i ,16 ]
I want to separate the real numbers : 11.3 , 32 , 9 ,16
how???

답변 (2개)

JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH 2019년 11월 11일
편집: JESUS DAVID ARIZA ROYETH 2019년 11월 11일

1 개 추천

solution:
A=[11.3 , 10+5i , 32 , 50+48i , 9 , 21+15i ,16 ]
onlyreals=A(imag(A)==0)
edit:
with cell array
A={ [ 1, 2+3i, 4, 5+6i ] , [7, 8+9i, 10, 11+12i ] , [13+14i, 15 ,16 ,17] };
B=cell(size(A));
for k=1:numel(A)
B{k}=A{k}(imag(A{k})==0);
end
disp(B)
masoud jiryaei
masoud jiryaei 2019년 11월 11일

0 개 추천

what about the cell array?
A={ [ 1, 2+3i, 4, 5+6i ] , [7, 8+9i, 10, 11+12i ] , [13+14i, 15 ,16 ,17] }

댓글 수: 1

with cell array
A={ [ 1, 2+3i, 4, 5+6i ] , [7, 8+9i, 10, 11+12i ] , [13+14i, 15 ,16 ,17] };
B=cell(size(A));
for k=1:numel(A)
B{k}=A{k}(imag(A{k})==0);
end
disp(B)

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

카테고리

도움말 센터File Exchange에서 Aerospace Blockset에 대해 자세히 알아보기

질문:

2019년 11월 11일

댓글:

2019년 11월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by