how can i separate real numbers?
    3 次查看(过去 30 天)
  
       显示 更早的评论
    
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???
0 个评论
回答(2 个)
  JESUS DAVID ARIZA ROYETH
      
 2019-11-11
        
      编辑:JESUS DAVID ARIZA ROYETH
      
 2019-11-11
  
      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)
0 个评论
  masoud jiryaei
 2019-11-11
        1 个评论
  JESUS DAVID ARIZA ROYETH
      
 2019-11-11
				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)
另请参阅
类别
				在 Help Center 和 File Exchange 中查找有关 LaTeX 的更多信息
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!