Problem using polyfit and syms in a for loop
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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?
Réponses (0)
Voir également
Catégories
En savoir plus sur Conversion Between Symbolic and Numeric dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!