Logarithmic plot of function using pchip
12 views (last 30 days)
Show older comments
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!
0 Comments
Answers (1)
Jonas
on 8 Jun 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
0 Comments
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!