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 Center および File ExchangeConversion 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