potential_calculation.m

来自「hodge decomposition for 2D vector fields」· M 代码 · 共 26 行

M
26
字号
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
function [potE,potW]=potential_calculation(mv_x,mv_y,mv_u,mv_v) 
%% potE: the curl-free potential function W 
%% potW: the divergence-free potential funciton W 
%% mv_x: horizontal coordinates of the grids 
%% mv_y: vertical coordinates of the grids 
%% mv_u: horizontal components of the input motion field 
%% mv_v: vertical components of the input motion field 
[M,N]=size(mv_x); 
S1=construct_S1(mv_x,mv_y); %% construct the element matrix S1 
[sa,sb]=size(S1); 
%Sr=S1(2:sa,2:sb); 
ISr=inv(S1(2:sa,2:sb)); 
potE=zeros(M,N); 
potW=zeros(M,N); 
[B,C]=construct_BC(mv_x,mv_y,mv_u,mv_v); %% construct the two vector B and C 
Br=B(2:sa); 
Cr=C(2:sa); 
Er=ISr*Br; %% solve for the (L-1)x1 vector Er 
Wr=ISr*Cr; %% solve for the (L-1)x1 vector Wr 
E_pot=[0;Er]; %% reconstruct the Lx1 vector E 
W_pot=[0;Wr]; %% reconstruct the Lx1 vector W 
potE=reshape(E_pot,M,N); %% re-organize the MxN potential surface E 
potW=reshape(W_pot,M,N); %% re-organize the MxN potential surface W 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?