- Flatten the matrices, since "polyfit" works only with vectors.
How can I find the coefficients of the 2D interpolated function?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
SPerera
el 1 de Ag. de 2024
Comentada: SPerera
el 1 de Ag. de 2024
My function is
. I used following code to interpolation. How can I find the coefficients of the
interpolated function
?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1744591/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1744596/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1744601/image.png)
Eta = load('Eta.txt');
t = 0:5:(8.25*60); % time
x = [0,3750,7500,8000]; % distance
[X,T] = meshgrid(x,t);
% interpolation
[xq,tq] = meshgrid(0:2:8000,0:(8.25*60)) ;
Eta_intp = interp2(X,T,eta,xq,tq,'spline');
0 comentarios
Respuesta aceptada
Animesh
el 1 de Ag. de 2024
Editada: Animesh
el 1 de Ag. de 2024
To find the coefficients of the 2-D interpolated function, we can use polynomial fitting on the interpolated data. You can use the "polyfit" function to do so in MATLAB.
Here is something you can try:
% Flatten the matrices
xq_flat = xq(:);
tq_flat = tq(:);
E_intp_flat = E_intp(:);
2. Perform polynomial fitting:
% Perform polynomial fitting
% Here, we assume a polynomial of degree 2 in both x and t
degree = 2;
p = polyfitn([xq_flat, tq_flat], E_intp_flat, degree);
disp(p.Coefficients);
Más respuestas (0)
Ver también
Categorías
Más información sobre Polynomials en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!