pv array mppt under partial shading code

10 visualizaciones (últimos 30 días)
ANCHITA JHA
ANCHITA JHA el 6 de Abr. de 2023
Respondida: Abhishek el 10 de Abr. de 2023
the following code for mppt is not working for partial shading condition.Is there any error
persistent p;
persistent v;
persistent dc;
persistent pbest ;
persistent counter ;
persistent gbest;
persistent u;
if(isempty(counter))
counter=1;
gbest= 0.5;
p=zeros(3,1);
v=zeros(3,1);
pbest=zeros(3,1);
u=1;
dc=zeros(3,1);
dc(1)=0.2;
dc(2)=0.4;
dc(3)=0.7;
end
for counter=1:1:10
for u=1:1:3
d=dc(u)
if((v_pv*i_pv)>p(u))
p(u)=(v_pv*i_pv);
v(u)=updatevelocity(v(u),pbest(u),dc(u),gbest);
dc(u)=updateduty(dc(u),v(u));
pbest(u)=dc(u);
end
end
[m,i]= max(pbest);
gbest=pbest(i);
end
d=gbest;
function vfinal=updatevelocity (velocity, pobest, d, gwbest)
w=0.1;
c1=1.2;
c2=1.2;
vfinal =(w*velocity)+(c1*rand(1)*(pobest-d))+(c2*rand(1)*(gwbest-d));
end
function dfinal=updateduty(d,velocity)
dup=d+velocity;
if(dup>1)
dfinal=1;
elseif(dup<0)
dfinal=0;
else
dfinal=dup;
end
end
end

Respuestas (1)

Abhishek
Abhishek el 10 de Abr. de 2023
Hi Anchita,
There are several issues with the code. Firstly, there is a missing function declaration at the beginning, which is essential for proper execution.
function d = myFunc
%your code
end
%helper functions
You can refer to the following link to understand how to declare a function in MATLAB: Declare function name, inputs, and outputs - MATLAB function (mathworks.com)
Furthermore, I noticed that the variables v_pv and i_pv are not defined in the nested for loop, causing the if condition to fail and resulting in the subsequent code block being skipped. It is recommended to either define these variables or pass them as arguments to the function.
if((v_pv*i_pv)>p(u)) %<----DEFINE these variables or INTAKE them as arguments to the function
Additionally, the condition to check for emptiness for counter in the eighth line, along with the declaration of u as 1, appears to be unnecessary. Moreover, there is no need to define u and counter variable as persistent if there isn't a specific reason to retain it in memory.

Categorías

Más información sobre Low-Level File I/O en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by