フィルターのクリア

Change of variables with a double integral

4 ビュー (過去 30 日間)
Melanie Wroblewski
Melanie Wroblewski 2022 年 11 月 18 日
編集済み: Zahrah Walid 2022 年 11 月 18 日
I have to write a code for changing variables from (x,y) to (u,v) with no in built matlab features. I am given four points in (x,y) and then told to transform it to (u,v) as (0,0) P1 to this point,(1,0) P2 to this point, (0,1) P3 to this point, and (1,1) P4 to this point. In our notes we are given that
x = au + bv +c or x = au + b and y = du + ev + f or y = cv + d to change the function from f(x,y) to f(u,v) given the new bounds as [0,1]X[0,1].
I'm just getting stuck on how to do this without any in built functions.

回答 (1 件)

Zahrah Walid
Zahrah Walid 2022 年 11 月 18 日
Example to illustrate the flow:
syms u v
%integration limits
x_min=0;
x_max=1;
y_min=2;
y_max=4;
F_original=@(x,y) x*y;
%variables relations
a_y=2;
b_y=3;
c_y=1;
a_x=1;
b_x=2;
c_x=3;
y= a_y*u+b_y*v+c_y;
x= a_x*u+b_x*v+c_x;
%change of limits (you can do it manually for simple relationships)
u_min=sym2poly(solve(a_y*u+b_y*v+c_y-y_min, a_x*u+b_x*v+c_x-x_min).u);
v_min=sym2poly(solve(a_y*u+b_y*v+c_y-y_min, a_x*u+b_x*v+c_x-x_min).v);
u_max=sym2poly(solve(a_y*u+b_y*v+c_y-y_max, a_x*u+b_x*v+c_x-x_max).u);
v_max=sym2poly(solve(a_y*u+b_y*v+c_y-y_max, a_x*u+b_x*v+c_x-x_max).v);
%change of respect value
dy_du=sym2poly(diff(y,u));
dy_dv=sym2poly(diff(y,v));
dx_du=sym2poly(diff(x,u));
dx_dv=sym2poly(diff(x,v));
sub_F=@(u,v) F_original(a_x*u+b_x*v+c_x,a_y*u+b_y*v+c_y).*dy_du*dy_dv*dx_du*dx_dv;
then preform the integration by the whatever method you prefer.
  2 件のコメント
Torsten
Torsten 2022 年 11 月 18 日
So
value1 = integral2(F_original,x_min,x_max,y_min,y_max)
value2 = integral2(sub_F,u_min,u_max,v_min,v_max)
should give the same value ?
But the values differ ...
Zahrah Walid
Zahrah Walid 2022 年 11 月 18 日
編集済み: Zahrah Walid 2022 年 11 月 18 日
You are right but I guess that the change of limits is the reason as it is not neccessarly that x lower limit occurs with y lower limit to results in u or v lower limits, it is related to the transformation of integration area new limits which may be not any combination between x and y limits; I was just showing the overall flow. For a simpler example with limits directly mapped, it works as required.
syms u v
%integration limits
x_min=0;
x_max=1;
y_min=2;
y_max=4;
F_original=@(x,y) x.*y;
%variables relations
a_y=2;
c_y=1;
a_x=1;
c_x=3;
y= a_y*u+c_y;
x= a_x*v+c_x;
%change of limits
u_min=sym2poly(solve(a_y*u+c_y-y_min, u));
u_max=sym2poly(solve(a_y*u+c_y-y_max, u));
v_min=sym2poly(solve(a_x*v+c_x-x_min,v));
v_max=sym2poly(solve(a_x*v+c_x-x_max,v));
%change of respect value
dy_du=sym2poly(diff(y,u));
dx_dv=sym2poly(diff(x,v));
sub_F=@(u,v) F_original(a_x*v+c_x,a_y*u+c_y).*dy_du*dx_dv;
value1 = integral2(F_original,x_min,x_max,y_min,y_max)
value2 = integral2(sub_F,u_min,u_max,v_min,v_max)
Sorry for inconvenience and many thanks for your comment

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAssumptions についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by