Find values of two variables corresponding to query points of two matrices.

1 次查看(过去 30 天)
If Ithere are 2 equations A(x,y) and B(x,y) that are functions of 2 varibles x, y. Suppose I set some values for x and y as vectors with lenghts i and k, respectively. Then I calclauted the matrices A (ixk) and B(ixk) corresponding to x, and y vectors.
How can I determine x, and y values for which A(x,y) and B(x,y) equal certain values (say v1 and v2) that are not in the calculaetd matrices?!
I think I should use "interpolation" but I don't know how I can apply it for this case.

回答(1 个)

Matt J
Matt J 2023-6-7
编辑:Matt J 2023-6-7
You should use fsolve or fminsearch to solve the original equations. Both of these are iterative solvers requiring an initial guess (x0,y0) of the solution.The matrices A and B can be used to do a discrete search for an approximate solution, which can serve as your (x0,y0):
[~,jmin]=min(hypot(A-v1,B-v2),[],'all','linear');
[x0,y0]=ind2sub([i,k], jmin);
x0=xvector(x0); y0=yvector(y0); %initial guess

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by