Substitute the nonlinearity in the linear system
Ältere Kommentare anzeigen
Hello everyone! I have a question about possibility of substituting some nonlinear function in system of lode’s.
For example, I have a system:
iN=1;%line
jN=2;%row
Nonlinearity=@(x) x^2;
[T,X]=ode45(@(t,x) odesys(t,x,Nonlinearity,iN,jN), [0 2],[0 0.1]
function RPF=odesys(t,x,Nonlinearity, iN, jN)
A=[0 1;0 -1];
B=[0 1];
A(iN,jN)=A(iN,jN)*Nonlinearity(x(jN))/x(jN);
RPF=A*x+B;
end
Obviously this works only if x(jN) does’nt equal zero during the integration progress, and I may suppose that this will produce some calculating errors because of dividing.
So I want to know is there better way to do this.
Thank you in advance!
Akzeptierte Antwort
Weitere Antworten (1)
Ivan Khomich
am 30 Jul. 2020
3 Kommentare
Walter Roberson
am 30 Jul. 2020
You should read the documentation for odeFunction and follow the flow in the first example, to come up with a numeric anonymous function to pass to ode45() . Doing symbolic calculations within your ode function is always going to be notably slower than numeric work, and so should be avoided unless there happen to be functions that are only implemented through the symbolic toolbox, or if you need higher precision or higher value range than numeric can give you
Ivan Khomich
am 31 Jul. 2020
Bearbeitet: Walter Roberson
am 31 Jul. 2020
Ivan Khomich
am 31 Jul. 2020
Kategorien
Mehr zu Symbolic Math Toolbox finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!