Problem using polyfit and syms in a for loop
1 次查看(过去 30 天)
显示 更早的评论
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 Center 和 File Exchange 中查找有关 Number Theory 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!