Logarithmic plot of function using pchip

11 vues (au cours des 30 derniers jours)
Lucas Weber
Lucas Weber le 8 Juin 2021
Réponse apportée : Jonas le 8 Juin 2021
Hello,
I got a problem with plotting a graph from distinct pairs of values.
My Code:
dil2f = [1 50 100 200 500 1000 2000 4000];
dil2an = [70.24 31.21 19.88 11.56 5.11 2.65 1.35 0.68];
xi = 0:.1:4000;
hold on;
Z1 = pchip(dil2f, dil2an, xi);
plot(xi, Z1);
xlabel("n [connections/day]");
ylabel("t_{lt} [years]");
set(gca, 'XScale', 'log')
set(gca, 'YScale', 'log')
xlim([1 4000])
grid on
grid minor
xticks([1 10 100 1000 4000])
xticklabels({'10^0', '10^1','10^2','10^3','4*10^3'})
which gives me this result:
As you can see the curve is not really smooth and seems to "wobble".
Am i using the wrong method for interpolation? Or do i miss something because of the logarithmic scale?
I am gladful for some help!!
Thanks in advance!

Réponses (1)

Jonas
Jonas le 8 Juin 2021
try interpolation in logarithmic space:
Z1 = 10.^(interp1(dil2f, log10(dil2an), xi,'pchip'));
or
Z1 = 10.^(pchip(dil2f, log10(dil2an), xi));
it looks already better than in your figure, you can try different methods in the interp1 function

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by