Can I implement a spatial derivative in a simscape custom component?
2 views (last 30 days)
Show older comments
I have an equation based off of two variables M and H. At some point in my equations I need to take the spatial derivative of H with respect to M like this: dM/dH. Then dM/dH is set equal to some expression that is also dependent on M and H. So think of it like the equation is dM/dH = x;
In a simscape custom component I can set a time based derivative dH/dt = x; How would I implement a spatial derivative in a custom component? I'm a little confused at the math because neither is based on time, but the simulation is always changing time and has a numerical solver that is time based. These derivatives are not dependent on time at all.
0 Comments
Answers (1)
Rollin Baker
on 12 Apr 2017
The beginning of your question is a bit unclear. You mention you want to take the derivative of H with respect to M, but you then go on to say you want to find dM/dH, which is actually the derivative of M with respect to H. For the purposes of answering your question, I will assume you mean to find dM/dH.
You say you have some equation that relates M and H. You will need to solve for M in this equation. Then you will have a function M(H). You can then find dM/dH by simply taking the derivative of this equation with respect to H. If you were trying to find dH/dM, just do the same process, but solve for H instead of M.
While the simulation is time-based, there is no requirement that you actually use the time measurements for anything. You can just create new vectors to represent the values that H and M are dependent on inside the "variables" or "parameters" section of the custom component.
Below I've linked a few documentation pages on the sections of Simscape components that may be relevant to you:
https://www.mathworks.com/help/physmod/simscape/lang/variables.html
https://www.mathworks.com/help/physmod/simscape/lang/parameters.html
Good luck with writing your custom component,
Rollin
0 Comments
See Also
Categories
Find more on 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!