Subscripted assignment dimension mismatch.

1 回表示 (過去 30 日間)
Marcus
Marcus 2015 年 2 月 26 日
回答済み: Star Strider 2015 年 2 月 26 日
Hello, I'm getting the error 'Subscripted assignment dimension mismatch.' for this piece of code:
a = -3;
b = 3;
M = 10^(5);
nrs = a + (b-a)*rand(2*M,1);
rng(:,1) = (nrs(1:length(nrs)/2));
rng(:,2) = (nrs(length(nrs)/2:end-1));
Could anyone help me to figure out what is wrong and how to fix it? Thank you very much.

採用された回答

Star Strider
Star Strider 2015 年 2 月 26 日
Your code as you posted it runs for me without error. Check to be sure you haven’t defined ‘rng’ earlier in your code.
Also, rng is a built-in MATLAB function, and you are ‘overshadowing’ it by naming your variable the same. Rename your variable something else, like ‘nrs_rng’.

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by