フィルターのクリア

How to send intermediate data(here duty cycle) sequentially from embedded function file to simulink block?

1 回表示 (過去 30 日間)
I m writing algorithm for Particle swarm optimization to find Maximum power point tracking in photo voltaics, in embedded matlab function. From algorithm i have to send three duty cycles sequentially to simulink converter block before the algorithn finishes.I use the following code.
function DC = PSO(V,I)
.................
DC=0;D=zeros(1,3);P=zeros(1,3);
..................
**********************************%%MAIN LOOP*************************
iter = 0 ; % Iterations’counter
while ( iter < bird_step )
iter = iter + 1;
for i = 1:3,
P(i)=V*I; %calculate power after a dutycycl sent
D(i)=current_dutycycl(i);
DC=D(i); %to send dutycycl
pause(0.1)
end
current_power=P;
for i = 1 : 3
if current_power(i) > local_best_power(i)
local_best_power(i) = current_power(i) ;
local_best_dutycycl(:,i) = current_dutycycl(:,i) ;
end
end
[current_global_best_power,g] = max(local_best_power);
if current_global_best_power > global_best_power
global_best_power = current_global_best_power;
for i=1:3
globl_best_dutycycl(:,i) = local_best_dutycycl(:,g);
end
end
velocity = w *velocity + c1*(R1.*(local_best_dutycycl-current_dutycycl)) + c2*(R2.*(globl_best_dutycycl-current_dutycycl));
current_dutycycl = current_dutycycl + velocity ;
end
[Peak_power,I] = max(current_power) % maximum power
current_dutycycl(:,I) % best solution
DC=current_dutycycl(:,I);% send dutycycl at each iteration
end
How to send duty cycle from for loop ... is ter any other way
  2 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 3 月 5 日
dalia elkashef commented
hello evry 1. im doing a simulation based on pso method to get a output from mppt which source by a solar. i am also in in beginer stage so i need your help to indicate how can i write code ? and how add it at simulink ? plsssssssssssssssssssss help me V Vaishnavi Kumar on
John D'Errico
John D'Errico 2014 年 3 月 18 日
dalia elkashef - Please don't add comments, then flag them to get attention. If you have a valid question, then ASK IT, separately as a question!
As it is, your question shows you are not making an effort to learn, just asking for someone else to do your work for you. The only way to learn is by trying, by making an effort.

サインインしてコメントする。

回答 (3 件)

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 10 月 23 日
The output is sent after the loop is finished. Use a for iterator subsystem .block
  2 件のコメント
V Vaishnavi Kumar
V Vaishnavi Kumar 2012 年 10 月 24 日
編集済み: V Vaishnavi Kumar 2012 年 10 月 26 日
while simulating i m getting an error as: "Error occurred while attempting to call the error callback function 'Stateflow.Translate.translate' of subsystem 'Solar_MPPT_Rloadstudy/PV panel/PV module' "in the adjacent PV module block, this same PV module working well with other algorithms.!............ what 's the reason for this......how to clear this error
John D'Errico
John D'Errico 2014 年 3 月 18 日
Don't flag your comments just to get attention.

サインインしてコメントする。


Abdullrahman Ali
Abdullrahman Ali 2014 年 3 月 20 日
Dear V Vaishnavi Kumar
I'm working with Genetic Algorithm (GA) and I'm facing the same problem. Did you solve the problem? Could you please tell me how?
  1 件のコメント
mohammed abdullrahman
mohammed abdullrahman 2014 年 10 月 9 日
i am working with DE (differential evolution)and have the same probleme any one help me please?

サインインしてコメントする。


Rahul Sugathan
Rahul Sugathan 2015 年 4 月 18 日
編集済み: Walter Roberson 2020 年 5 月 16 日
i dont think u can send the duty cycle from a for loop. U must use a persistent and ifisempty combination.
Here's how u send 3 different values,
function DC=fcn %#codegen
persistent u
if isempty(u)
u = 0;
end
u=u+1;
if(u==1)
DC=15;
pause(0.1);
elseif(u==2)
DC=29;
pause(0.1)
else
DC=50;
pause(0.1);
end

カテゴリ

Help Center および File ExchangeSolar Power についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by