How do I increase accuracy of set point or increase accuracy of steady state error for a Matlab genetic algorithm live script?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I am trying to make my system have a better steady state although it seems that matlab believes the system is actucally reaching 5 volts although it clearly is somewhere in the region of 4.95 volts. I am not sure how to make matlab more accuracte in detailing the setpoint so that my system can more accurately reach the set point. There may be the case that the system cannot reach 5v exactly but I would prefer it being more accuracte than a steady state error of 0.05v.
In short how can I increase the accuracy of matlab or change the script so that the setpoint to be reached is 5.0000 rather than what it belivies to be 5v (it thinks 4.95v is close enough i believe)
---------------------------------------------------------First script----------------------------------------------
clear all, close all, clc
dt = 0.000001; % this is 10^-6
PopSize = 55; % was 500
MaxGenerations = 25; %was 1000
s = tf('s');
G =(1439928003.68621)/(s*s+5333.33333333333*s+95995200.2457475)
options = optimoptions(@ga,'PopulationSize',PopSize,'MaxGenerations',MaxGenerations,'OutputFcn',@myfun);
[x,fval] = ga(@(K)pidtest(G,dt,K),3,-eye(3),zeros(3,1),[],[],[],[],[],options);
-------------------------------------------------------Second script--------------------------------------------------------
function J = pidtest(G,dt,parms)
s = tf('s');
K = parms(1)+ parms(2)/s + parms(3)*s/(1+0.000001*s)
Loop = series(K,G);
ClosedLoop = feedback(Loop,1);
t = 0:dt:1.5; % this indicates length of time to show
[y,t] = step(ClosedLoop,t);
CTRLtf = K/(1+K*G);
u = lsim(K,1-y,t); % line to potenially change for different TFs
Q = 1;
R = 0.000005; % change these to effect rise, overshoot, settling time?
J = dt*sum(Q*(1-y(:)).^2 + R*u(:).^2)
step(5*ClosedLoop,t)
h = findobj(gcf,'type','line');
set(h,'linewidth',2);
drawnow
--------------------------------------------------------------------------------------------------------------------------
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/530454/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/530459/image.png)
0 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Genetic Algorithm 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!