I have an x and y vector, of sizes n and m respectively. I also have a z matrix of size n by m.
I am trying to do one of the following, preferably both:
- interpolate for given x and y values to find the value of z
- find a 2D function with inputs x and y using fit
In either scenarios, I am not sure whether I can do this since my x and y's are of different sizes. For the second option, which isn't as straight forward, I have the following code:
where my fit function, as seen in the code, is: (a+b*x+c*x^2)+(d+e*x+f*x^2)*sin(y)+(g+h*x+i*x^2)*cos(y). The constants a,b,c,d,e,f,g,h,i are the one which I want fit to find me. Unfortunately, this does not work for different sized arrays.
EDIT: I've found a solution that may work but it turns out I cannot call the independent variables as [M,aoa]. The code is now:
myfittype = fittype('(a+b*Mx+c*Mx^2)+(d+e*Mx+f*Mx^2)*sin(aoax)+(g+h*Mx+ii*Mx^2)*cos(aoax)',...
This returns the following error:
Operator '<' is not supported for operands of type 'fittype'.
Error in fit (line 7)
if dim_x < m