I have 4 values of B corresponding to 4 values of A. I need 100 values of B for 100 values of A. There is no well defined interval between two values of A but values of A are within the range 0.049317 to 0.160588. Can anyone help me to find out

1 回表示 (過去 30 日間)
A =
[0.049317,
0.0892293,
0.120183,
0.160588]
B =
[3.3976e+05,
3.4549e+04,
8.1311e+03,
4.4150e+03]

採用された回答

Image Analyst
Image Analyst 2014 年 9 月 22 日
Since you don't have uniform spacing in the A/x values then you can't use interp1() to get the new A/x values or B/y values. Try spline or scatteredInterpolant. My spline demo is attached. Spline will give you evenly spaced values for the new A's but your original A's will be at the same locations (with uneven spacing). I don't know how you can guess at the B values for those new A values unless you have some formula relating the two.

その他の回答 (3 件)

Star Strider
Star Strider 2014 年 9 月 23 日
編集済み: Star Strider 2014 年 9 月 23 日
A power function actually fits it reasonably well, but without knowing the process that created your data, any function approximation is a leap of faith:
yf = @(b,x) b(1).*x.^b(2);
p = nlinfit(A, B, yf, [B(1); 1])
x = linspace(min(A), max(A));
ye = yf(p,x);
figure(1)
plot(A, B, '*b')
hold on
plot(x, ye, '-r')
hold off
The function with fitted parameters becomes:
B = 2.7*A^(-3.9)

Matt J
Matt J 2014 年 9 月 22 日
How about
Bmore = interp1(A,B,linspace(A(1), A(end),100))
  1 件のコメント
Image Analyst
Image Analyst 2014 年 9 月 22 日
That will give what he called "well defined intervals" which I think should be fine. Maybe he meant that only for the initial A and not for the bigger A. If he really needs to have "no well defined intervals" inthe new, bigger A I guess he could use rand instead of linspace, or just include the original 4 A values
newXValues = sort([A, linspace(A(1), A(end), 96)]);
Bmore = interp1(A,B, newXValues)

サインインしてコメントする。


Roger Stafford
Roger Stafford 2014 年 9 月 23 日
With just four pairs you just as well use a Lagrange interpolating polynomial. In your case it would be a cubic. It has no requirements of sorting or range.
http://en.wikipedia.org/wiki/Lagrange_polynomial

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by