필터 지우기
필터 지우기

fitting function of two variables

조회 수: 20 (최근 30일)
SAM alimostafa
SAM alimostafa 2011년 5월 18일
답변: Image Analyst 2013년 12월 19일
hi could any one help me on this problem: i have a vector x with some values and vector y with some values too,y isn't function of x and i need to fit them in a function f(x,y)how can i do this in matlab??
  댓글 수: 2
Yoav Livneh
Yoav Livneh 2011년 5월 18일
Can you clarify? Are you trying to find the relation between x and y (y=f(x)) or are both x and y inputs into f which an output z (z=f(x,y))?
SAM alimostafa
SAM alimostafa 2011년 5월 18일
i mean that i need z=f(x,y)

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

답변 (3개)

Ivan van der Kroon
Ivan van der Kroon 2011년 5월 18일
If you have a predevined function, f(x,y) with unknown coefficients, you can find those with the optimalization toolbox.
If you're just wondering how to do it for multiple vectors, I always concatenate them. If your arrays are constraints (so known values) remember that the vector to be optimized are the coefficients of your function.
Sorry, lot of if's, but your question is not really clear to me.
Good luck, Ivan
  댓글 수: 1
SAM alimostafa
SAM alimostafa 2011년 5월 18일
i mean that i need to apply least square method to fit a function of two variables x and y

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


Yoav Livneh
Yoav Livneh 2011년 5월 18일
You can use fminsearch to optimize your coefficients, but you still need to know the basic form of the function. Write a function (in my example it's called "my_fun") that for every pair of (x,y) values compares (subtracts) f(x,y) to the data you want to fit it to. It's inputs are the coefficients you want to optimize. Then write:
coeffs_init = [1 1 1] % Initial guess of coefficients. Can be any size, depending on number of coefficients.
Results = fminsearch(@(t)my_fun(t,x,y,Comp_Data),coeffs_init);
I hope I made myself clear. If not I'll try and rephrase. You can also type in the command line "doc fminsearch" to see examples.
  댓글 수: 3
Arun Jose
Arun Jose 2013년 12월 19일
z=f(x,y) is my function.but i know data points (x ,y) and corresponding z values only. I know that z is of the form z=a*g(x,y)+b*h(x,y) i want find a,b in a least squre sense. Can i use 'lsqcurvefit' function?? If i can't what can i use??
Alan Weiss
Alan Weiss 2013년 12월 19일
This example might help. It has z = f(x), but just take [x,y] as your x and you'll be fine.
Alan Weiss
MATLAB mathematical toolbox documentation

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


Image Analyst
Image Analyst 2013년 12월 19일
I use polyfitn http://www.mathworks.com/matlabcentral/fileexchange/34765-polyfitn to fit a 2D vignetted background image to a quadratic. See attached demo below in blue.

카테고리

Help CenterFile 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!

Translated by