The following gives an error and I don't know why. The code runs perfectly when I leave '(i_testen)' away behind 'Enkel_hoek_afg'.
for i_testen=1:5
...
Enkel_hoek_afg(i_testen) = Enkel_hoek(1:Afg_c_RANK_RKNE(2,1))
end
Error: In an assignment A(I) = B, the number of elements in B and I must be the same.

 採用された回答

Star Strider
Star Strider 2014 年 12 月 19 日

0 投票

See if this solves it:
for i_testen=1:5
...
Enkel_hoek_afg(i_testen,:) = Enkel_hoek(1:Afg_c_RANK_RKNE(2,1))
end
This assumes ‘Enkel_hoek(1:Afg_c_RANK_RKNE(2,1))’ is a row vector of constant length.
If it is not, create a cell array instead:
Enkel_hoek_afg{i_testen} = Enkel_hoek(1:Afg_c_RANK_RKNE(2,1))
Note that here, curly brackets ‘{}’ replace parentheses ‘()’ on the left-hand side of this assignment.

6 件のコメント

Sam
Sam 2014 年 12 月 19 日
Matlab still gives an error :(
Star Strider
Star Strider 2014 年 12 月 19 日
Does it throw an error for the cell array? It shouldn’t.
If it throws an error for the first option:
Enkel_hoek_afg(i_testen,:) = Enkel_hoek(1:Afg_c_RANK_RKNE(2,1))
what are the row and column sizes of ‘Enkel_hoek’?
What is the value stored in ‘Afg_c_RANK_RKNE(2,1)’ when it throws the error?
Sam
Sam 2014 年 12 月 19 日
編集済み: Sam 2014 年 12 月 19 日
It gives the following error: Subscripted assignment dimension mismatch. Enkel_hoek is 677x1 Afg_c_RANK_RKNE is 2x1 and has values 0 for (1,1) and 328 for (2,1). But this value 328 changes for each measurement.
Star Strider
Star Strider 2014 年 12 月 19 日
If the length changes with each iteration, use my cell array solution instead:
Enkel_hoek_afg{i_testen} = Enkel_hoek(1:Afg_c_RANK_RKNE(2,1))
Note that here, curly brackets ‘{}’ replace parentheses ‘()’ on the left-hand side of this assignment.
Sam
Sam 2014 年 12 月 20 日
Strange, when I tried it the first time it didn't work. Now I've tried it again, and it works... Well, thanks a lot!
Star Strider
Star Strider 2014 年 12 月 20 日
My pleasure!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Type Identification についてさらに検索

タグ

質問済み:

Sam
2014 年 12 月 19 日

コメント済み:

2014 年 12 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by