필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Any idea to convert numerics to symbolic ?

조회 수: 1 (최근 30일)
Stephan Moeller
Stephan Moeller 2014년 6월 2일
마감: MATLAB Answer Bot 2021년 8월 20일
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

답변 (4개)

Andreas Goser
Andreas Goser 2014년 6월 2일
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.

Stephan Moeller
Stephan Moeller 2014년 6월 2일
yes, me too. But there isn't anything already available as a function ?
  댓글 수: 2
Andreas Goser
Andreas Goser 2014년 6월 2일
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.
Stephan Moeller
Stephan Moeller 2014년 6월 2일
편집: Stephan Moeller 2014년 6월 2일
yeah, you're right ! Thanks :-)

pietro
pietro 2014년 6월 2일
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
Stephan Moeller
Stephan Moeller 2014년 6월 2일
I meant without explizit writing all numerics maunally.
pietro
pietro 2014년 6월 2일
편집: pietro 2014년 6월 2일
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
Andrei Bobrov 2014년 6월 2일
편집: Andrei Bobrov 2014년 6월 2일
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
Stephan Moeller
Stephan Moeller 2014년 6월 2일
out = a*exp(b*x)+loge(c*x+d)+e
log10 is lost ...

이 질문은 마감되었습니다.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by