Problem using polyfit and syms in a for loop

조회 수: 1 (최근 30일)
Bob
Bob 2014년 12월 14일
댓글: Image Analyst 2014년 12월 14일
Here is my code.
Z=[3 1];
for i=1:length(Z);
syms a
x=5*a-Z(:,i)
A(i)=solve(x,a);
syms b
y=3*a+Z(:,i)
B(i)=solve(y,b);
A(i)=Z(i)+2;
B(i)=Z(i)-7;
xfit=[0 1];
yfit1(:,i)=[A(i),B(i)]
pfit1(:,i)=polyfit(xfit1,yfit1(:,i),1);
pval1(i,:)=polyval(pfit1(i,:),xfit1);
The error message I am getting is:
Error using polyval: Inputs must be floats, namely single or double.
I tried running a similar code and without the syms part and the code worked fine. How do I get my code to work with syms?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by