- what is TL and how it changes with time?
- why do you use y(4) as C(t)?
How can I solve a system of differential equations including a bounded proportional controller?
2 views (last 30 days)
Show older comments
Hello there,
I am kindly asking for help because I got stuck on this issue.
What I want to do is solve a set of differential equations which rely on a controller. The set of equations is as follows:
where M and F are constants. C(t) is the bounded proportional controller on which the system relies on, and which is given by the following:
where TL is a 2007x1 double vector. LD and LR is a constant.
I have tried to solve it by using the ode 45 function and by modelling the controller with an if-else statement. The script I have been using is as follows:
time=daten(8:end,2);
time_min=time/60;
T0=daten(8,2);
T0_min=T0/60;
tEnd=daten(end,2);
tEnd_min=tEnd/60;
Fext=daten(8:end,3)*100; %_deltoideus_anterior_part1 in %
Fext_statisch=daten(8,3)*100;
MVC=100;
TL=Fext/MVC; %Target Load in % of MVC
timerange=[T0_min tEnd_min];
IC=[MVC;0;0;0];
[t,y]=ode45(@(t,y) freylaw(t,y,time_min,TL),timerange,IC);
figure
plot(t,y(:,1));
hold on
plot(t,y(:,2));
hold on
plot(t,y(:,3));
xlabel('time[min]');
ylabel('Force of various compartments [N]');
legend('MR','MA','MF')
and the function I am calling in the ode45 statement is as follows:
function y=freylaw(t,y,time_min,TL)
L=10; %model-specific factor (LD=LR=5)
r=15; %rest-recovery-multiplier according to Looft et al.(2018)
F=0.00912; %fatigue factor according to Frey Law (2012)
R=0.00094; %recovery factor according to Frey Law (2012)
y(1)=-y(4)+(R+r)*y(3); %Mr the constant r is introduced here according to Looft et al.(2018) and is an intended variation of the original equation
y(2)=y(4)-F*y(2); %Ma
y(3)=F*y(2)-R*y(3); %Mf
if (y(2)<TL)&(y(3)>(TL-y(2)))
y(4)=L*(TL-y(2)); %if Ma<TL and Mr>(TL-Ma)
elseif (y(2)<TL)&(y(1)<(TL-y(2)))
y(4)=L*y(1); %if Ma<TL and Mr<(TL-Ma)
else
y(4)=L*(TL-y(2)); %if Ma>=TL
end
end
The problem I am encountering is, that my result is just my initial condition stretched over the whole time range. But actually Ma should be a varying curve, and Mf should increase, and Mr should decrease. I guess that there is some issue with the if-statement I am using to model the bounded controller. But I am unsure on what to change and I am hoping some of you might give me some great tips! Thanks a lot!
2 Comments
darova
on 18 Feb 2020
Can you please explain more:
Accepted Answer
darova
on 18 Feb 2020
Edited: darova
on 18 Feb 2020
Interpolate TL to choose correct value
Don't use y(4) for Ct
function dy=freylaw(t,y,time_min,TL)
L=10; %model-specific factor (LD=LR=5)
r=15; %rest-recovery-multiplier according to Looft et al.(2018)
F=0.00912; %fatigue factor according to Frey Law (2012)
R=0.00094; %recovery factor according to Frey Law (2012)
tt = linspace(0,1.6*60,length(TL)); % time array in seconds
TL0 = interp1(tt,TL,t); % choose current TL
if (y(2)<TL0)&&(y(1)>(TL0-y(2)))
Ct=L*(TL0-y(2)); %if Ma<TL and Mr>(TL-Ma)
elseif (y(2)<TL0)&&(y(1)<(TL0-y(2)))
Ct=L*y(1); %if Ma<TL and Mr<(TL-Ma)
else
Ct=L*(TL0-y(2)); %if Ma>=TL
end
dy(1,1)=-Ct+(R+r)*y(3); %Mr the constant r is introduced here according to Looft et al.(2018) and is an intended variation of the original equation
dy(2,1)=Ct-F*y(2); %Ma
dy(3,1)=F*y(2)-R*y(3); %Mf
end
Small mistake
Edited: dy name of result variable
6 Comments
darova
on 12 Mar 2020
- Does that make sense to you?
Not really actually
(dimensionless value)
You can operate only with the same dimensions
MVC=100-y(2)) that means that y(2) and MVC are the same dimension (Newtons)
You can't substract values/number of different dimensions
You code looks ok. The only comment i have: check dimensions
More Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations 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!