![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/342637/image.jpeg)
Plotting a graph through the points
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello everyone,
I have collected this experimental data from the lab where x is time with 1 being 1 second 70 being 70 seconds and so on. I want the reading in y as points in which a curve can go through. Furthermore, I would like to insert this line into the same graph as my model. How do I do this? I have attached my code below for the plotting from the model.
x = [1 70 140 210 280 350 420 490 560 630 696]
y = [65.08 60.7 55.83 50.43 44.56 38.55 31.98 25.43 18.68 11.11 0]
figure (2)
plot(t(a),CAD(a),'Linewidth',2)
grid on
xlabel ('Time (s)')
ylabel ('\theta (\circ)')
title ('Contact Angle vs Evaporation Time')
legend('Theoretical','Experimental')
Thanks in advance for the help.
0 commentaires
Réponse acceptée
dpb
le 6 Août 2020
Modifié(e) : dpb
le 6 Août 2020
plot(x,y,'*-','LineWidth',2);
b1=polyfit(x,y,1);
y1=polyval(b1,[x(1),x(end)]);
hold on
plot([x(1),x(end)],y1,'r:');
b2=polyfit(x,y,2);
y2=polyval(b2,[x(1):x(end)]);
plot([x(1):x(end)],y2,'r-');
yields
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/342637/image.jpeg)
The quadratic seems to do a very nice job -- of course, don't even try to use it to extrapolate more than a very, tiny, tiny, amount.
Plus de réponses (1)
Sudheer Bhimireddy
le 6 Août 2020
You mean fitting a curve or polynomial function through the points?
0 commentaires
Voir également
Catégories
En savoir plus sur Get Started with Curve Fitting Toolbox 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!