Differentiation error - conversion of variable type problem - 'struct' to function
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Tam Ho
am 29 Dez. 2017
Beantwortet: Walter Roberson
am 29 Dez. 2017
I ran this code:
syms theta %create symbolic variable theta
assume(theta,'real') %theta is real
f = fit_v2; %calling our fitted polynomials
g = diff(f,theta);
g0=solve(g,theta);
double(g0);
I get this error:
Error using sym>tomupad (line 1251)
Unable to convert 'struct' to 'sym'.
Error in sym (line 215)
S.s = tomupad(x);
Error in sym/privResolveArgs (line 988)
argout{k} = sym(arg);
Error in sym/diff (line 21)
args = privResolveArgs(S,varargin{:});
Error in code (line 54)
g = diff(f,theta);
please help! Thanks!
Akzeptierte Antwort
Walter Roberson
am 29 Dez. 2017
poly = poly2sym(f.coeff, theta);
g = diff(poly, theta)
However, you do not need the symbolic toolbox to differentiate a polynomial with numeric terms, and you do not need the symbolic toolbox to get the roots of a polynomial with numeric terms (you can use roots())
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Conversion Between Symbolic and Numeric finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!