Extracting polynomial coefficients from function handle

조회 수: 5 (최근 30일)
meysam esmaeeli
meysam esmaeeli 2015년 12월 30일
댓글: meysam esmaeeli 2015년 12월 30일
I have an unknown large polynomial function handle. for example: f=@(x) 1234*x^2000+654*x^1982+....
I want to extract its coefficients. I know that i Can use a code like this:
%
syms y
coefficients=sym2poly(f(y));
%
but its too slow beacause i need this to repeat in a loop more than 10000 times.
is there any way to extract coefficient directly from function handle???

답변 (1개)

Andrei Bobrov
Andrei Bobrov 2015년 12월 30일
reshape(str2double(regexp(func2str(f),'\d*(?=\*x\^)|(?<=\*x\^)\d*','match')),2,[])'
  댓글 수: 1
meysam esmaeeli
meysam esmaeeli 2015년 12월 30일
i said that my polynomial function handle is unknown. in fact it is in a form like this:
%
A = @ (x,a1,a2,a3) [x^2+a1,...]
f = @(x) det (A(x,1,5,6))

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by