Logarithmic plot of function using pchip
조회 수: 5 (최근 30일)
이전 댓글 표시
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
답변 (1개)
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
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!