How can I join two rectangular grids of different size to make one grid?
5 views (last 30 days)
Show older comments
I have a code for calculating flow through a tank. It works for a simple geometry (one tank, or one rectangle) that is divided into a grid made up of x and y points. For example:
Lx = 300; % Geometry length in x direction
Ly = 150; % Geometry length in y direction
Nx = 10; Ny = Nx; % Number of points in x and y direction
% Grid
x = linspace(0,Lx,Nx); y = linspace(0,Ly,Ny);
delta_x = Lx/(Nx-1); delta_y = Ly/(Ny-1);
I want to add an inlet/pipe to the tank (a second rectangle joined to the first), but I can't figure out how to do it. I have tried:
c = [0 150 150 0 ]; % x dimension of large tank
d = [0 0 150 150]; % y dimension of large tank
v = [0 20 0 20 ]; % x dimension of inlet
w = [150 200 200 0]; % y dimension of inlet
x = union(c(1,:), v(1,:));
y = union(d(1,:), w(1,:));
grid_val = 10;
figure('Color','w');
[X,Y] = meshgrid(min(x):grid_val:max(x), min(y):grid_val:max(y));
But instead of a large rectangle joined to a smaller rectangle on top, with both divided into square grid cells, I get a strange triangular grid shape. I am not very experienced with Matlab, so it is likely I'm making a simple mistake. I also tried creating grids separately and then concatenating them, but I always get dimensions errors. If anyone could help, I would be very grateful. Maybe this is not even possible in Matlab?
0 Comments
Answers (0)
See Also
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!