I don;t know how to fix this error

1 visualizzazione (ultimi 30 giorni)
myrto pieridou
myrto pieridou il 1 Lug 2022
Risposto: Prateekshya il 5 Set 2023
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 Commento
Stephen23
Stephen23 il 1 Lug 2022
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?

Accedi per commentare.

Risposte (1)

Prateekshya
Prateekshya il 5 Set 2023
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!

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by