Predict y values from x values
古いコメントを表示
If x=[0 1 2 3 4 5]; and y=[0 20 60 68 77 110]; To get a linear equation I can use coefficients=polyfit(x,y,1) which gives me coefficients 20.8286 3.7619 so my linear equation is y = 20.8286 x + 3.7619 If I want to find an unknown y value from a known x value e.g. 1.5 I can use y=polyval(coefficients, 1.5) and I get y = 35.0048. In other words, using polyval, and using the equation derived from polyfit, when x = 1.5, y = 35.0048.
However, if I want to find an unknown x value from a known y value, what do I do?
Kind regards, Wendy
採用された回答
その他の回答 (1 件)
"Predict y values from x values"
>> x = [0,1,2,3,4,5];
>> y = [0,20,60,68,77,110];
>> ynew = 35;
>> xnew = interp1(y,x,ynew)
xnew = 1.3750
You can see how this value actually fits into your data:
>> plot(x,y,'-',xnew,ynew,'*')

カテゴリ
ヘルプ センター および File Exchange で Get Started with Curve Fitting Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!