the error " Assignment has more non-singleton rhs dimensions than non-singleton subscripts" when happen?

9 ビュー (過去 30 日間)
K=128;
N=4;
QPSk_Set=[1 -1 1j -1j];
Phase_Set=[1 -1];
MAX_SYMBOLS=1e5;
PAPR_Orignal=zeros(1,MAX_SYMBOLS);
PAPR_SLM=zeros(1,MAX_SYMBOLS);
X=zeros(N,K);
Index=zeros(N,K);
for nSymbol=1:MAXSYMBOLS
Index(1,:)=randi(1,K,length(QPSK_Set))=1;
Index(2:N,:)=randi(N-1,Klength(Phase_Set))+1;
end
the error ' Index(1,:)=randi(1,length(QPSk_Set))+1 '
I need help ! How do i solve it??

採用された回答

Jan
Jan 2018 年 11 月 19 日
編集済み: Jan 2018 年 11 月 19 日
There is an orphaned "= 1" in the line:
Index(1,:)=randi(1,K,length(QPSK_Set))=1;
% ^^
MAXSYMBOLS is not defined, but MAX_SYMBOLS is.
In
Index(2:N,:)=randi(N-1,Klength(Phase_Set))+1;
% ^^
there is an unknown character. Simoply delete it and retype the comma.
QPSK_Set is not defined also, but only QPSk_Set with an lower-case "k".
After fixing these typos, the line is failing:
Index(1,:)=randi(1,K,length(QPSk_Set))
because the left-hand-side is [1 x 128] and the right-hand-side [128 x 4]. Due to the lack of comments it is not clear, what the code should do, so all I can do is guessing:
Index(1,:)=randi(length(QPSK_Set), 1, K)
Finally you overwrite Index(1,:) in each iteration. This is not useful.
  1 件のコメント
long zhang
long zhang 2018 年 11 月 21 日
'Index(1,:)=randi(1,K,length(QPSK_Set))+1'
Thank you very much , this seems to be working for me!
Bravo!

サインインしてコメントする。

その他の回答 (1 件)

dpb
dpb 2018 年 11 月 19 日
編集済み: dpb 2018 年 11 月 19 日
Index(1,:)=randi(1,K,length(QPSK_Set))=1;
appears a typo; above wouldn't run. But, the error as given is because the size of subscripting expression (1,:) is a column vector of K elements but you generated a Kx4 array from |randi(1,K,length(QPSK_Set))|. You can't put a 128x4 array into one column; the error is telling you that.

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by