Generating co-efficient of polynomial equation using polyfit with for loop
Mostrar comentarios más antiguos
for n=1:4
res(n,:)=polyfit(fandata.x1,fandata.y1,6);
end
fandata______________
x1 y1 y2 y3 y4
0 420 620 820 1020
10 373 550 727 903
20 340 500 660 820
30 313 460 607 753
40 293 430 567 703
50 273 400 527 653
60 259 378 497 617
70 243 355 467 578
---------------------------------
i need to get coeffiecient of each y1,y2,y3... data polynomial (curve) and to load in 'res' table. So for that i need to iterate y colounm in the above for loop.
How to write the code to loop
2 comentarios
Chuguang Pan
el 9 de Dic. de 2019
Maybe you could convert table fandata to a array. Following is my method.
A = table2array(fandata); %Convert fandata table to array(matrix) A
for n=1:4
res(n,:)=polyfit(A(:,1),A(:,n+1),6);
end
Mohammed Hablullah
el 9 de Dic. de 2019
Respuestas (0)
Categorías
Más información sobre Polynomials en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!