Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

please help to solve this error " In an assignment A(:) = B, the number of elements in A and B must be the same." . code is attached in zip file.

조회 수: 1 (최근 30일)
please help to solve this error " In an assignment A(:) = B, the number of elements in A and B must be the same." . code is attached in zip file.
  댓글 수: 1
Wick
Wick 2018년 5월 4일
can you help me how can i solve this problem. because i tried a lot to solve this one but could not got successs.
Since x_stage1 has two elements, you may only assign one to x_temp(stage). So it could be
x_temp(stage) = abs(x_temp1(1)).*y;
For example. Whether you pick the first or second element - or whether you need to assign both to x_temp in another way is up to you to decide.

채택된 답변

Wick
Wick 2018년 5월 4일
You're trying to assign a [1, 2] vector to a [1, 1] scalar.
x_temp(stage) = abs(x_temp1).*y;
'stage' is a single value, so x_temp(stage) is also going to be a single value. 'x_temp1' has a value of [-0.4825 - 0.0181i 0.2444 - 0.3996i] on the first loop. That's two complex elements. Taking the absolute value will yield [0.4828 0.4685] - still two elements.
Did you intend for the long string of numbers to not be assigned to anything? It looks like you wanted them to be assigned to y but only the first number actually is.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by