How to update a live variable that is changing with time-step
Ältere Kommentare anzeigen
Hi,
I am having some trouble translating the second equation from this set:

For the equation: M_y = K_d * (dBeta/dt); the values for "Beta and "t" need to be calculated at each time-step using finite differentiation method.
From my understanding this would essentially amount to the value of M_y being defined as:

The values for Beta and t are variables that change at each time step, in this case t is a variable from a solver file that implements the ode45 solver, and Beta is a radian scalar that is determined at each timestep by an equation to calculate the angle between the Y-axis of a satellite and a local magnetic field vector.
My question is how can I translate the equation above into matlab code? I have tried sing diff function but the array size I get causes errors in the later solvers. Can this be acheved using loop functions or is there a way for matlab to store a variable at each time-step, so that it can be used for a calculation at the next time-step? Any advice, resources or other guidance would be really appreciated.
This code is the control algorithm to detumble a satellite. All required code is attached in the "Live_models.zip" file.
Thank you
Antworten (0)
Kategorien
Mehr zu Loops and Conditional Statements 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!