linear fit in Log Scale + extension
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Niklas Kurz
le 16 Juin 2020
Commenté : Niklas Kurz
le 17 Juin 2020
Hello, also this question might be trivial and frequently answered, but yet again I'm not able to grasp it. Long story short, that's what I got:
ind = f>=5000& f <= 10000
p = polyfit(f(ind),qU(ind),1);
t = polyval(p,(f(ind)));
plot(f(ind),t,'-r','Linewidth',3);
actually this looks like a straight line to me, even if I set:
set(gca,'XScale','log')
set(gca,'YScale','log')
However I want to extend this line, lets say to [5000 15000]. How can I finally achieve this? Thx in advance
0 commentaires
Réponse acceptée
David Hill
le 16 Juin 2020
Modifié(e) : David Hill
le 16 Juin 2020
ind = f>=5000& f <= 10000
p = polyfit(f(ind),qU(ind),1);%you will always get a line if degree is 1
x=5000:15000;
t = polyval(p,x);
plot(x,t,'-r','Linewidth',3);
3 commentaires
David Hill
le 17 Juin 2020
p1 = polyfit(f(1:2),qU(1:2),1);%however many points you want
p2 = polyfit(f(3:end),qU(3:end),1);%second line
x=5000:15000;
t1 = polyval(p1,x);
t2 = polyval(p2,x);
plot(x,t1,'-r',x,t2,'-g','Linewidth',3);
Plus de réponses (1)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!