Passing computations from ODE45

  • Thread starter Thread starter adschutte
  • Start date Start date
  • Tags Tags
    Ode45
AI Thread Summary
To pass variables computed within a user-defined function called by ODE45 in MATLAB, such as the variable Fc in the provided example, one effective approach is to use nested functions or handle functions. By defining Fc as a persistent variable or using a global variable, it can be accessed outside the function without needing to recompute it. Alternatively, consider using a structure to store multiple outputs, including Fc, which can then be returned alongside the primary outputs of the ODE function. This method allows for efficient data management and avoids unnecessary calculations. Additionally, embedding the ODE function within a larger script can facilitate variable sharing without the need for external files.
adschutte
Messages
1
Reaction score
0
Does anyone know a trick to pass variables computed in the user defined function called by ODE45 in MATLAB?

For example, imagine you have the following code:

%=======================================
[t,y] = ode45('DiffEQ',dt,Initial,options);

function dy = DiffEQ(t,y)
Fc = y(1)*y(2);
dy(1) = y(2);
dy(2) = -k*y(1)-c*y(2)+Fc;
%=======================================

How can we pass Fc as an output? I don't want to re-compute Fc with the solutions. Thanks for any tips.
 
Computer science news on Phys.org
Save it in a file or embed the code in a bigger one. Is not very consuming to do an ode45.
 
I came across a video regarding the use of AI/ML to work through complex datasets to determine complicated protein structures. It is a promising and beneficial use of AI/ML. AlphaFold - The Most Useful Thing AI Has Ever Done https://www.ebi.ac.uk/training/online/courses/alphafold/an-introductory-guide-to-its-strengths-and-limitations/what-is-alphafold/ https://en.wikipedia.org/wiki/AlphaFold https://deepmind.google/about/ Edit/update: The AlphaFold article in Nature John Jumper...
Thread 'Urgent: Physically repair - or bypass - power button on Asus laptop'
Asus Vivobook S14 flip. The power button is wrecked. Unable to turn it on AT ALL. We can get into how and why it got wrecked later, but suffice to say a kitchen knife was involved: These buttons do want to NOT come off, not like other lappies, where they can snap in and out. And they sure don't go back on. So, in the absence of a longer-term solution that might involve a replacement, is there any way I can activate the power button, like with a paperclip or wire or something? It looks...
Back
Top