How to index nested symbolic arrays

2 ビュー (過去 30 日間)
Roberto
Roberto 2014 年 1 月 21 日
回答済み: Roberto 2014 年 1 月 22 日
When you execute a MuPAD function that returns a list, I mean inside Matlab by means of feval(symengine,etc.), what should you expect to be returned in Matlab? Let me explain with a practical example, the function poly2list. The Example 2 in the reference is:
poly2list((x*(y + 1))^2, [x, y])
that returns the list [[1, [2,2]], [2,[2,1]], [1,[2,0]]]. But what about
A=feval(symengine,'poly2list',(x*(y + 1))^2)
instead? I get a 1x3 sym array but i can't figure out how to index it! Evaluating A(1,1) I obviously get [1, [2,2]] but i don't know how to index the 1 or the [2,2]. Thanks in advance!

回答 (1 件)

Roberto
Roberto 2014 年 1 月 22 日
I (partially) found an answer by myself. Basically I pass the output of 'poly2list' to 'matrix' and i get a result that is quite easy to handle with Matlab. In fact I use
feval(symengine,'matrix', feval(symengine,'poly2list', polynomial) )
Improvements of my answer or better solutions are welcome!

Community Treasure Hunt

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

Start Hunting!

Translated by