How to generate a TFI (Transfinite Interpolation) based grid in MATLAB for a given analytical equation? (code provided)

7 次查看(过去 30 天)
I have a code for a general equation, but I want the equations to be based on the following figure. I'm not able to get the function for the curve shown.
clc
clear all ;
% number of discretizations along xi and eta axis
m = 10 ;
n = 10 ;
% discretize along xi and eta axis
xi = linspace(0.,1,m) ;
eta = linspace(0.,1.,n) ;
% Initialize matrices in x and y axis
X = zeros(m,n) ;
Y = zeros(m,n) ;
for i = 1:m
Xi = xi(i) ;
for j = 1:n
Eta = eta(j) ;
% Transfinite Interpolation
XY = (1-Eta)*Xb(Xi)+Eta*Xt(Xi)+(1-Xi)*Xl(Eta)+Xi*Xr(Eta)......
-(Xi*Eta*Xt(1)+Xi*(1-Eta)Xb(1)+Eta(1-Xi)Xt(0)+(1-Xi)(1-Eta)*Xb(0)) ;
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.
X(i,j) = XY(1) ;
Y(i,j) = XY(2) ;
end
end
plotgrid(X,Y) ;
function xyb = Xb(s)
x = s ;
y = 0 ;
xyb = [x ; y] ;
end
function xyl = Xl(s)
x = 0 ;
y = s ;
xyl = [x ; y] ;
end
function xyr = Xr(s)
x = 1+2*s-2*s^2 ;
y = s ;
xyr = [x ; y] ;
end
function xyt = Xt(s)
x = s ;
y = 1-3*s+3*s^2 ;
xyt = [x ; y] ;
end
function plotgrid(X,Y)
% plotgrid: To plot structured grid.
%
% plotgrid(X,Y)
%
% INPUT:
% X (matrix) - matrix with x-coordinates of gridpoints
% Y (matrix) - matrix with y-coordinates of gridpoints
if any(size(X)~=size(Y))
error('Dimensions of X and Y must be equal');
end
[m,n]=size(X);
% Plot grid
figure
set(gcf,'color','w') ;
axis equal
axis off
box on
hold on
% Plot internal grid lines
for i=1:m
plot(X(i,:),Y(i,:),'b','linewidth',1);
end
for j=1:n
plot(X(:,j),Y(:,j),'b','linewidth',1);
end
hold off
end

回答(1 个)

Sachin Lodhi
Sachin Lodhi 2023-11-17
Hi Chinmay,
From what I gather, you are facing error while generating a TFI (Transfinite Interpolation) based grid in MATLAB for an analytical equation.
The error is caused due to missing multiplication symbols in the syntax of analytical equation. After substituting the below line in the code, you can generate the TFI based grid.
XY = (1-Eta)*Xb(Xi)+Eta*Xt(Xi)+(1-Xi)*Xl(Eta)+Xi*Xr(Eta)-(Xi*Eta*Xt(1)+Xi*(1-Eta)*Xb(1)+Eta*(1-Xi)*Xt(0)+(1-Xi)*(1-Eta)*Xb(0));
I hope this helps.
Best Regards,
Sachin

类别

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

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by