indexing complex numbers
8 次查看(过去 30 天)
显示 更早的评论
hi,
I'm trying to index the arrays of as explained below.
a = [-1+i 1+i 1+i 1+i -1+i -1-i -1+i 1+i 1-i -1+i -1-i -1+i -1-i -1-i -1+i -1-i]
b = [00 01 11 10]
-1+1 will be replaced by 00
1+i will be replaced by 01
1-i will be replaced by 11
-1-i will be replaced by 10
the problem is that, any method of indexing i try gives me the same error message saying "Subscript indices must either be real positive integers or logicals." Pls i dnt knw wat to do.
Thanks in advance
0 个评论
采纳的回答
Rick Rosson
2011-11-25
x = ( 1 + real(a) ) / 2;
y = ( 1 - imag(a) ) / 2;
b = [ y ; x ];
3 个评论
Walter Roberson
2011-11-25
It will only work for +/-1 +/-1*i . If you have other fixed sets of values with fixed mappings, sometimes you can create simple mapping expressions like Rick shows, and sometimes you cannot.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!