problem in matlab code
이전 댓글 표시
Hello,
Please how i can solve this problem in my Matlab code:
In an assignment A(:) = B, the number of elements in A and B must be the same.
Error in ObjectiveFunction (line 73)
throughputCR(i)= throughputCR(i)+W*log2(1+ SinrCR(i,j));
Error in PSO (line 94)
Swarm.Particles(k).O = fobj(currentX);
Error in main (line 54)
[ GBEST , cgcurve ] = PSO( noPa , maxItera , visFlaga ) ;
>>
답변 (2개)
Image Analyst
2019년 8월 4일
W is probably a vector and so the entire right hand side is a vector. You can't stuff, say, 100 elements into throughputCR(i) which is just a single element.
If you put these lines before the bad line, what does it report in the command window?
whos throughputCR
whos W
whos SinrCR
댓글 수: 3
brahmi ibtissem
2019년 8월 5일
Guillaume
2019년 8월 5일
The problem is still the same, population.Chromosomes(indx(1)).fitness is a vector, a matrix, or is empty. I.E: it's not just one element. And you try to assign it to a single element of a variable.
Image Analyst
2019년 8월 5일
brahmi, why did you not put in the whos statements like I specifically asked you for? You're just delaying an answer by not doing the things we suggest.
KALYAN ACHARJYA
2019년 8월 4일
A= B;
댓글 수: 7
brahmi ibtissem
2019년 8월 4일
KALYAN ACHARJYA
2019년 8월 4일
Then What does this line means?
Inn an assignment A(:) = B,
Share complete code.
Guillaume
2019년 8월 5일
"In an assignment A(:) = B, the number of elements in A and B must be the same" is the generic error message you get (in some versions of matlab) when you attempt an indexed assigment with mismatched size. The error message does not replace A and B by the names of the offending variables.
brahmi ibtissem
2019년 8월 5일
Walter Roberson
2019년 8월 5일
Show us the code for ObjectiveFunction
brahmi ibtissem
2019년 8월 6일
Walter Roberson
2019년 8월 6일
global W;
You do not show us where you initialized W. W might be its default value for a global variable, which is to say it might be empty.
카테고리
도움말 센터 및 File Exchange에서 Particle Swarm에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!