Adopting Genetic algorithm for a Simulink model without feedback loop

6 ビュー (過去 30 日間)
vinusan
vinusan 2023 年 2 月 21 日
編集済み: Sam Chak 2023 年 2 月 21 日
this is the marx impulse model created in simulink. want to get the rise time - 1.2 us(micro seconds), fall time -50 us, by adjusting the resistance and capacitance values with the help of genetic algorithms. how to do that

回答 (1 件)

Sam Chak
Sam Chak 2023 年 2 月 21 日
編集済み: Sam Chak 2023 年 2 月 21 日
I'm unfamiliar with your Simulink model as well as the cost function that is related to Rise Time and Fall Time. However, you can basically call the ga() function using the script below to return the vector k that consists the local optimum resistance R and capacitance C values.
You are advised to study some examples here:
fun = @costfun;
[k, fval, exitflag, output] = ga(fun, nvars, A, b, Aeq, beq, lb, ub, nonlcon, options)
function J = costfun(k)
t0 = 0; % start time
tf = 20; % final time
h = 1e-2; % time step size
opts = simset('SrcWorkspace', 'current', 'DstWorkspace', 'current');
simOut = sim('MySimulinkModel', [t0:h:tf], opts); % Simulink file
cumJ = simOut.logsout.get(1).Values.Data; % cumulative_J
J = cumJ(end);
end

カテゴリ

Help Center および File ExchangeGenetic Algorithm についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by