Can't get the code into the for loop
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
Dear all, Please help me to get the attached code into the for loop. The code must run for j=1:length(Pd). Two variables are varying with every 'j' - Pd(j) and no_units(j). Of course the sizes of Pd and no_units are the same. I'm able to run it in a for loop for different Pd, but it doesn't work when I include no_units.
Many thanks, George.
댓글 수: 5
Kevin Xia
2017년 8월 7일
When I put the code in a for loop, I get the following error:
Error using *
Inner matrix dimensions must agree.
Error in LoopTest (line 29)
sigma=B(i,:)*Pg-B(i,i)*Pg(i);
The code fails because B is a 6x6 matrix, while Pg is a num_units x 1 vector. Pg needs to be a 6x1 vector for the matrix multiplication to work. Does the size of Pg need to depend on no_units?
George Ansari
2017년 8월 7일
George Ansari
2017년 8월 8일
KL
2017년 8월 8일
it doesn't work when I include no_units
show us what you've tried. Simply attaching your m-file and asking us to do your work is not the point.
답변 (0개)
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!