Logarithmic plot of function using pchip

12 ビュー (過去 30 日間)
Lucas Weber
Lucas Weber 2021 年 6 月 8 日
回答済み: Jonas 2021 年 6 月 8 日
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!

回答 (1 件)

Jonas
Jonas 2021 年 6 月 8 日
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

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by