I am having trouble with some basic plotting using the polyval function.
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Here is my question I am tackling: Fit a second-order polynomial to the data from Table 14.1. In one figure, plot the data and the polynomial curve you obtained. V(m/s): 10 20 30 40 50 60 70 80 F (N): 25 70 380 550 610 1220 830 1450
I thought it would just require a simple polyfit polyval but I must not understand how to do it. Here is my attempt
v = [10 20 30 40 50 60 70 80];
F = [25 70 380 550 610 1220 830 1450];
x=linspace(0,100,0.1);
P=polyfit(v,F,2);
Q=polyval(P,x);
plot(v,F,'b*'), hold on
plot(Q,'r-')
If someone could help me that would be appreciated. Also if you could display what the final 2nd order polynomial is, or at least its coefficients, that would be so helpful!
0 Commenti
Risposte (1)
Guillaume
il 8 Ott 2017
Modificato: Guillaume
il 8 Ott 2017
The only issue I see in your script is
x=linspace(0,100,0.1);
which asks for a grand total of 0.1 points between 0 and 100. Matlab rounds that down to 0 points, hence x is empty.
_edit: and the last plot needs x values unless x has a step of 1 and starts at 1.
0 Commenti
Vedere anche
Categorie
Scopri di più su Polynomials in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!