unexpected object of type 'RootOf'

6 views (last 30 days)
Mert sargin
Mert sargin on 18 Jul 2022
Edited: Mert sargin on 19 Jul 2022
Hi everyone, I am trying to perform a simple curvefitting, but Matlab keeps throwing this error message at me. Does anyone know whats the issue?
It is weird that I only encounter this problem when I try to work with the function Aufheiz6Var, but I get no issues when working with Aufheiz4var and Aufheiz2Var, they are almost exactly the same functions but just different equations.
Error using symengine
Code generation failed due to unexpected object of type
'RootOf'.
res1 = mupadmex('symobj::generateMATLAB',r.s,ano,spa,splitIt);
r = mup2mat(c{1},true,sparseMat,false);
body = mup2matcell(funs, opts.Sparse);
gs=matlabFunction(ilaplace(Zges*rect))
Error in 1515 (line 55)
bx=@(start)Aufheiz6var(Res(i-2),Res(i-1),Res(i),Cap(i-2),Cap(i-1),start,Zth,time(i,:),aufheizdauer);
Error in fminsearch (line 201)
fv(:,1) = funfcn(x,varargin{:});
if i==2
Zth=temp(i,:)/PHI;
Res(i)=Zth(aufheizdauer)-Res(i-1);
bx=@(start)Aufheiz4var(Res(i-1),Res(i),Cap(i-1),start,Zth,time(i,:),aufheizdauer);
AufheizParameter=fminsearch(bx,start);
Cap(i)=AufheizParameter;
end
if i==3
Zth=temp(i,:)/PHI;
Res(i)=Zth(aufheizdauer)-Res(i-1)-Res(i-2);
bx=@(start)Aufheiz6var(Res(i-2),Res(i-1),Res(i),Cap(i-2),Cap(i-1),start,Zth,time(i,:),aufheizdauer);
AufheizParameter=fminsearch(bx,start);
Cap(i)=AufheizParameter;
end
function A=Aufheiz6var(R1,R2,R3,C1,C2,C3,Zth,xm,aufheizdauer)
syms s
Z3=R3/(R3*C3*s+1);
Z2=(R2+Z3)/((R2+Z3)*C2*s+1);
Z1=R1+Z2;
Zges=1/(s*C1+1/Z1);
rect=(1-exp(-s*aufheizdauer))/s;
gs=matlabFunction(ilaplace(Zges*rect))
A=sum((gs(xm)-Zth).^2);
clf;
plot(xm,Zth,'b');
hold on;
plot(xm,gs(xm),'r');
drawnow
end
function A=Aufheiz4var(R1,R2,C1,C2,Zth,xm,aufheizdauer)
syms s
Z2=R2/(R2*C2*s+1);
Z1=R1+Z2;
Zges=1/(s*C1+1/Z1);
rect=(1-exp(-s*aufheizdauer))/s;
gs=matlabFunction(ilaplace(Zges*rect));
A=sum((gs(xm)-Zth).^2);
clf;
plot(xm,Zth,'b');
hold on;
plot(xm,gs(xm),'r');
drawnow
end

Accepted Answer

Paul
Paul on 18 Jul 2022
I'm going to speculate that the denominator of Zges*rect in Aufheiz6Var is of too high of an order for the Symbolic Math Toolbox to be able to factor exactly as it would need to do for ilaplace(). Unless you need closed-form expressions, consider not using the SMT at all, and instead use the Control Systems Toolbox to generated the time responses.
  7 Comments
Mert sargin
Mert sargin on 19 Jul 2022
Edited: Mert sargin on 19 Jul 2022
I cant thank you enough. You are such a blessing. Its working now.

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!