How to generate function handle automatically from the cell array?
Afficher commentaires plus anciens
I have a 2x1 cell called "dx", which contains 1x3 cells:
'X * k * m' '*' '-1'
'X * k * m' '*' 'Y_XS'
I want this "dx" cell to be converted into a function. How can I do that? The generated function should look like this:
function dX = myFunc(t,X,k,m,Y_XS)
R = X(2) * k * X(1)/(X(1)+m);
dX = [-R;
Y_XS * R];
5 commentaires
Is it strictly required to write a file, or would it be enough to generate a function handle? Writing files is slow.
"How can I do that without usind the symbolic Toolbox?"
Why would you need to use the symbolic toolbox? You have a cell array of char vectors: all you need to do is open a text file, write those char vectors in the order of your choice using fprintf, and close the file when you are done.
Akbar
le 13 Avr 2018
@Akbar Shadakov: It would help if you gave a bit more information:
- Does the cell array always have the same size?
- Does the second column always contain binary operators?
- Can the third column contain other variables?
- Is the cell (1,3) always a constant?
- Where are x, y and z specified? (are they symbolic?)
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Symbolic Math Toolbox 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!