Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Any idea to convert numerics to symbolic ?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
How can I convert an equation with the numeric coeffs to symbolic ?
example :
y= 2*exp(3*x)+log10(4*x+9)+10
so I get
y= a1*exp(a2*x)+log10(a3*x+a4)+a5
0 comentarios
Respuestas (4)
Andreas Goser
el 2 de Jun. de 2014
I can think of string operations. But you need to find rules how to smartly cover situations where you don't want to replace a number with a variable like in x.^2.
0 comentarios
Stephan Moeller
el 2 de Jun. de 2014
2 comentarios
Andreas Goser
el 2 de Jun. de 2014
Don't think so. I never heard of such an operation. Instead of numerics to symbolic I would also rather call it "generalizing coefficients" or so. But exactly because if this difficulty to name it, it is also difficult to search for it. Lets see if more people reply.
pietro
el 2 de Jun. de 2014
You can use the symbolic toolbox. Here an example:
syms z,x
z=3*x; y=subs(z1,{3},{a})
With a workaround I think you can do what you need
2 comentarios
pietro
el 2 de Jun. de 2014
Editada: pietro
el 2 de Jun. de 2014
you can write your formula in symbolic way, then using symvar you can get the symboli variables:
y=2*exp(3*x)+log10(4*x+9)+10 Then with symvar you can get the variables.
symvar(y)
ans =
x
so you can get everything since operators and functions are known. After having got the numeric values, you can substitute them using subs
Hope this helps
Andrei Bobrov
el 2 de Jun. de 2014
Editada: Andrei Bobrov
el 2 de Jun. de 2014
x= 'a':'z';
z = '2*exp(3*x)+log10(4*x+9)+10';
dd = regexp(z,'(?<=[\(-*/+ ])\d*|\d*(?=[+*-/\)])','match');
out = regexprep(z,dd',cellstr(x(1:numel(dd))'));
1 comentario
La pregunta está cerrada.
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!