save loop data, matrix- matlab, yalmip
Show older comments
Hi, I'm stuck on generating and keeping the outputs matrix.
As the matrix B contains 't', I should use 'for loop' to generate each solution 'PfeasibleR'
When I run it, only one solution 'PfeasibleR' at t=2 is shown. What I've done was using preallocated variable, PfeasibleR= zeros(2, 18);
Can I get some tips to save value of 'PfeasibleR' per each matrix 'B'?
ops = sdpsettings('solver','mosek','verbose',1,'debug',1);
K= 0.01; %motor torque constant= electromotive force constant
La= 0.5;%electric inductance
b= 0.1;% motor viscous friction constant
J= 0.001;%moment of inertia of the rotor
Va= 140; %armature voltage constant
Ra= 0.5;%armature electirc resistance
PfeasibleR= zeros(2, 18);
for t=0.4:0.2:2
A= [-(Ra)/La 0; 0 -b/J];
B= [0; ((K*Va)./(J*Ra))*(1-exp(-(Ra./La)*t))];
D= [0, -K./La; K./J, 0];
I=eye(1);
e_1 = 0.8;
y=sdpvar(2,1);
Pr=sdpvar(2,2);
x = sdpvar(2,1);
M=[Pr*A'+ A*Pr+ B*y'+ y*B'+ e_1*D*Pr*D' , y; y' , -e_1];%LMI
conR=[Pr>=0, M<=0]; %constraints
obR= -log(det(Pr)); %objective
optimize(conR, obR, ops)
PfeasibleR = value(Pr);%(2x2)
yfeasibleR = value(y);%(2x1)
K_R = (yfeasibleR)'/(PfeasibleR);%(1x2)
end
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!