The graph basic fitting tool accepts a matrice but not the polyfit function... How to do the same thing in a script ?
Mostrar comentarios más antiguos
I made a graph of the evolution of a variable through 10 time periods (colums) for 10 individuals (lines). The graph basic fitting gives a nice fourth degree fit which I want to reproduce in a script for different variables. I tried with polyfit but it doe not take a matrice as input. Could somebody tell me how to replicate the treatment of the basic fittiing tool in a script ? Here is the graph and the data in DATA.mat attached file.
Thanks alot for any help.

Respuesta aceptada
Más respuestas (1)
Antoni Garcia-Herreros
el 27 de Mzo. de 2023
Hello,
Something like this might do the trick:
close all
for i=1:10; % Loop through your variables
p=polyfit([1:10]',vcz(:,i)',4);
YT=polyval(p,T);
p1=plot([1:10],vcz(:,i));
L=legend;
hold on
p2=plot(T,YT,'LineWidth',2);
L.String{end}=['Fitted ' L.String{end-1}];
end
Hope this helps!
1 comentario
Jacques Larue
el 27 de Mzo. de 2023
Categorías
Más información sobre Logical 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!
