How to find the best fit curve as a vertical scaling of another curve?

조회 수: 5 (최근 30일)
SojM
SojM 2021년 9월 20일
댓글: SojM 2021년 9월 22일
I have a original graph of function f(x). Now I have few points scattered and I want to find a best fit curve through these points. But my new fit curve should be of the form n*f(x) where n is a numerical value. I want to find the value n. How can I do this? Below figure might explain the problem I am talking about. I want to fit curve n*f(x) through orange points and find out n.

채택된 답변

David Goodmanson
David Goodmanson 2021년 9월 20일
편집: David Goodmanson 2021년 9월 20일
Hi SojM,
Suppose you have points x,y for the function f(x), where x and y are column vectors. And suppose the red points are the set xr,yr, also both column vectors. Then
ynew = interp1(x,y,xr,'spline');
n = ynew\yr
If you have f(x) as an algebraic function, then the first line can be simply
ynew = f(xr)
  댓글 수: 1
SojM
SojM 2021년 9월 22일
Thanks. This is what I was looking for. Is there any way to put this into a for loop when x and y are same but there are multiple column vectors data (xr, yr)?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by