Storing and retrieving mathematical equations

12 次查看(过去 30 天)
Hi everyone,
I'm trying to create some mathematical equations and store them some how in struct or cells. My equations contains highly nonlinear terms and they are chosen from vast range of possibilites, which also includes delay terms. For example
Equation 1 : G(t) = [X(t)^2 X(t-4)^2 X(t)*Y(t) Z(t) X(t)^2*Z(t) X(t)*Y(t-4) ] * [theta_1,....................,theta_6]';
Equation 2 : G(t) = [X(t)^3 X(t-2)^2 X(t-2)*Y(t-2) X(t)*Y(t) X(t-2)*Y(t) ] * [theta_1,..........................theta_5];
There are atleast 100 of this equations and i need to pick best model by comparing the error. Firstly, I don't know how to store this equations and then I thought of converting them in to 'string' and retrieving back using eval() command. But, i read lot of comments suggesting it is a bad way to store and retrieve equations.
Can someone suggest me an alternative and efficient way to store and retrieve equations?
Thanks

采纳的回答

madhan ravi
madhan ravi 2019-5-10
An example :
syms x
G = cell(3,1);
for k=1:3
G{k} = matlabFunction(k*x^2);
end
G{2}(4) % 2 second eqn & 4 argument of the eqn

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

产品


版本

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by