Problem using polyfit and syms in a for loop
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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?
Respuestas (0)
Ver también
Categorías
Más información sobre Conversion Between Symbolic and Numeric en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!