Making a plot smooth
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have two vectors.I need to make the smooth plots.But I am getting straight lines which are not appealing.Kindly suggest me any way of having smooth plots.
I have following data
x=[0 0.025 0.05 0.075 0.1 0.125 0.15 0.175 0.2 0.225 0.25 0.275 0.3 0.325 0.35 0.375 0.4 0.425 0.45 0.475 0.5 0.525 0.55 0.575 0.6 0.625 0.65 0.675 0.7 0.725 0.75 0.775 0.8 0.825 0.85 0.875 0.9 0.925 0.95 0.975 1 ] ;
y=[1.422 1.427 1.431 1.396 1.396 1.377 1.377 1.358 1.357 1.338 1.338 1.319 1.318 1.301 1.301 1.288 1.287 1.278 1.278 1.274 1.274 1.275 1.276 1.282 1.282 1.294 1.294 1.309 1.310 1.328 1.328 1.348 1.348 1.367 1.367 1.386 1.386 1.413 1.413 1.039 1.025] ;
plot(x,y,'r')
Thank You
0 Commenti
Risposte (1)
Walter Roberson
il 9 Ott 2020
x=[0 0.025 0.05 0.075 0.1 0.125 0.15 0.175 0.2 0.225 0.25 0.275 0.3 0.325 0.35 0.375 0.4 0.425 0.45 0.475 0.5 0.525 0.55 0.575 0.6 0.625 0.65 0.675 0.7 0.725 0.75 0.775 0.8 0.825 0.85 0.875 0.9 0.925 0.95 0.975 1 ] ;
y=[1.422 1.427 1.431 1.396 1.396 1.377 1.377 1.358 1.357 1.338 1.338 1.319 1.318 1.301 1.301 1.288 1.287 1.278 1.278 1.274 1.274 1.275 1.276 1.282 1.282 1.294 1.294 1.309 1.310 1.328 1.328 1.348 1.348 1.367 1.367 1.386 1.386 1.413 1.413 1.039 1.025] ;
sp = spline(x, [0 y 0]);
xq = linspace(min(x), max(x), 25);
yq = ppval(sp, xq);
plot(x, y, 'g', xq, yq, 'r')
If you increase the 25 to make the curve more accurate then although it will be smoother than the raw data, it will still show a lot of bumps.
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!