필터 지우기
필터 지우기

Symbolic or function handle to numeric

조회 수: 1 (최근 30일)
Drew Mitchell
Drew Mitchell 2016년 4월 20일
답변: Walter Roberson 2016년 4월 21일
Is there a way to turn a symbolic expression or function handle into a numeric expression? For example, say i have:
syms x
y=x^2;
and would like to turn it into to this
y=x^2;
Where x is no longer a symbolic variable such that when I give x a value like
x=[1 2 3];
and I type
y
I get
y=[1 4 9];
I know function handles will do this but matlab coder can not take function handles, so is there a way to do this?
Thanks
Drew

답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 4월 20일
편집: Azzi Abdelmalek 2016년 4월 20일
syms x;
y=x^2;
out=subs(y,[1 2 3])
  댓글 수: 3
Azzi Abdelmalek
Azzi Abdelmalek 2016년 4월 20일
편집: Azzi Abdelmalek 2016년 4월 20일
have you tried inline function?
y=inline('x.^2')
Drew Mitchell
Drew Mitchell 2016년 4월 20일
That is also not supported by coder.
I appreciate the responses though Thanks!!

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2016년 4월 21일
syms is not supported by the coder either. So anything having to do with symbolics has to be done and over with before code is generated. At the time you are running the symbolic code, you can use matlabFunction to write to a file.

카테고리

Help CenterFile Exchange에서 Function Creation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by