Passing Functions and m-files to functions
Afficher commentaires plus anciens
Hi Mathworks,
I have an m-file which codes up a system of differential equations;
9D_system
This has various parameters in it, and I have a few parameter schemes for specifying the values to these parameters;
P1.m, P2.m, P3.m
I want to be able to specify which parameter scheme I endow the system with, and then solve this system of differential equations with ode15s.
How do I do this?
Moreover, the parameter schemes
P1.m, P2.m, P3.m
each call functions (some of the parameters are functions of other parameters, and so must be calculated by these called functions). Thus the ode will have a series of nested functions being called!!
Any help on this would be greatly appreciated. :)
Linford
1 commentaire
José-Luis
le 12 Fév 2013
Pass them as a string and evaluate inside your function.
Réponse acceptée
Plus de réponses (2)
Azzi Abdelmalek
le 12 Fév 2013
f=@P1
f=@P2
José-Luis
le 12 Fév 2013
myStr = 'P1.m'
function [result] = myFun(someArg, myStr)
[str str] = fileparts(myStr);
run(str); %calling your script
%Do your thing
1 commentaire
Linford Briant
le 12 Fév 2013
Modifié(e) : Linford Briant
le 12 Fév 2013
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!