I don;t know how to fix this error
조회 수: 1 (최근 30일)
이전 댓글 표시
clear all
define_constants;
mpc=loadcase('case24_ieee_rts');
demand=[1775.835,1669.815,1590.3,1563.795,1563.795,1590.3,1961.37,2279.43,2517.975,2544.48,2544.48,2517.975,2517.975,2517.975,2464.965,2464.965,2623.995,2650.5,2650.5,2544.48,2411.955,2199.915,1934.865,1669.815]
time=[1:1:24];
%proportional load distribution
tot_load=0;
for i=1:1:24
tot_load=tot_load+mpc.bus(i,PD);
end
load_prc=mpc.bus(:,PD)./tot_load;
a=1;
c=1;
for i=1:1:24
mpc.bus(:,PD)=load_prc.*demand(i);
if i==19
for a <= 33 the error is 'Invalid use of operator'
mpc.gen([a],GEN_STATUS)=0
mpc.gen([1],GEN_STATUS)=0
c=c+1;
normal(i)=runpf(mpc);
voltage=normal(19).bus(:,VM)
T=table(voltage)
댓글 수: 1
Stephen23
2022년 7월 1일
It looks like you are trying to write a WHILE loop, not a FOR loop.
CLEAR ALL is unlikely to be required: why does your script need to remove cached functions from memory?
답변 (1개)
Prateekshya
2023년 9월 5일
As per my understanding you are getting "invalid use of operator" error in the line where "for loop" is written. In MATLAB, the “for-loop” syntax is as follows:
for a = 1 : k : n
% Your code here
end
This syntax ensures that the loop will start from “1” and go up to “n” with a step size of “k”. For example: “1 : 2 : 5” means the loop with run over the values 1, 3 and 5. Please make sure to change the conditional statement to the range mentioned above as well as to mark the "end" of the for loop in your code. In your case the value of “n” will be 33. You may find more information regarding the same here: https://in.mathworks.com/help/matlab/ref/for.html
Hope this helps!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!