Email: [email protected]

This Portal for internal use only!

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • IBM
  • Visual Paradigm
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Office
      • Windows
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Categories
  • Microsoft
    • Microsoft Apps
    • Office
    • Operating System
    • VLS
    • Developer Tools
    • Productivity Tools
    • Database
    • AI + Machine Learning
    • Middleware System
    • Learning Services
    • Analytics
    • Networking
    • Compute
    • Security
    • Internet Of Things
  • Adobe
  • Matlab
  • Google
  • Visual Paradigm
  • WordPress
    • Plugin WP
    • Themes WP
  • Opensource
  • Others
More Categories Less Categories
  • Get Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • My Account
    • Download
    • Cart
    • Checkout
    • Login
  • About Us
    • Contact
    • Forum
    • Frequently Questions
    • Privacy Policy
  • Forum
    • News
      • Category
      • News Tag

iconTicket Service Desk

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • IBM
  • Visual Paradigm
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Office
      • Windows
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Menu
  • Home
    • Download Application Package Repository Telkom University
    • Application Package Repository Telkom University
    • Download Official License Telkom University
    • Download Installer Application Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • All Pack
    • Microsoft
      • Operating System
      • Productivity Tools
      • Developer Tools
      • Database
      • AI + Machine Learning
      • Middleware System
      • Networking
      • Compute
      • Security
      • Analytics
      • Internet Of Things
      • Learning Services
    • Microsoft Apps
      • VLS
    • Adobe
    • Matlab
    • WordPress
      • Themes WP
      • Plugin WP
    • Google
    • Opensource
    • Others
  • My account
    • Download
    • Get Pack
    • Cart
    • Checkout
  • News
    • Category
    • News Tag
  • Forum
  • About Us
    • Privacy Policy
    • Frequently Questions
    • Contact
Home/Matlab/Regarding grid generation using finite difference method (*code fixed)

Regarding grid generation using finite difference method (*code fixed)

PuTI / 2025-04-07
Regarding grid generation using  finite difference method (*code fixed)
Matlab News

Hi everyone,
I’m trying to generate a uniform grid where the red lines intersect at a 45-degree angle to the horizontal lines in blue using the finite difference method in MATLAB.
However, the resulting grid is slightly off, as shown in the attached image. Intesection angle is uniform but higher than 45-degree.
I set computational domain as and a grid is generated on physical domain with coordinates .
As I want to generate a mesh described above, I aimed to solve the following PDE :

where we have (horizontal lines). The boundary conditions are .
The above equation comes down to the following:

Based on the above equation, I discretized to finite difference form (central difference for and forward differece for ).
Plus, I found the grid collapses when I set different angles (for example 90-degree (replace )).
Am I missing something in implementation?

I need your help.
Here is my code.
% Parameter settings
eta_max = 10;
xi_max = 10;
Delta_eta = 0.1;
Delta_xi = 0.1;
tol = 1e-6;
max_iterations = 100000;

% Grid size
eta_steps = floor(eta_max / Delta_eta) + 1;
xi_steps = floor(xi_max / Delta_xi) + 1;

% Initial conditions
x = zeros(eta_steps, xi_steps);
y = repmat((0:eta_steps-1)’ * Delta_eta, 1, xi_steps);

% Boundary conditions
x(1, 🙂 = linspace(0, xi_max, xi_steps);

% Finite difference method
converged = false;
iteration = 0;

while ~converged && iteration < max_iterations
iteration = iteration + 1;
max_error = 0;

for n = 1:eta_steps – 1
for m = 2:xi_steps – 1
x_xi = (x(n, m+1) – x(n, m-1)) / (2 * Delta_xi);
y_xi = (y(n, m+1) – y(n, m-1)) / (2 * Delta_xi);

new_x = x(n, m) + Delta_eta * ((pi/4) – y_xi)/(x_xi);
error_x = abs(new_x – x(n, m));
max_error = max([max_error, error_x]);

x(n + 1, m) = new_x;
end

x(n+1, xi_steps) = x(n+1, xi_steps-1) + Delta_xi;
x(n+1, 1) = x(n+1, 2) – Delta_xi;
end

if max_error < tol
converged = true;
end
end

% Plot the results
figure; hold on; axis equal; grid on;

for m = 1:xi_steps
plot(x(:, m), y(:, m), ‘r’);
end

for n = 1:eta_steps
plot(x(n, :), y(n, :), ‘b’);
end

title([‘Iterations until convergence: ‘, num2str(iteration)]);
xlabel(‘x’); ylabel(‘y’);Hi everyone,
I’m trying to generate a uniform grid where the red lines intersect at a 45-degree angle to the horizontal lines in blue using the finite difference method in MATLAB.
However, the resulting grid is slightly off, as shown in the attached image. Intesection angle is uniform but higher than 45-degree.
I set computational domain as and a grid is generated on physical domain with coordinates .
As I want to generate a mesh described above, I aimed to solve the following PDE :

where we have (horizontal lines). The boundary conditions are .
The above equation comes down to the following:

Based on the above equation, I discretized to finite difference form (central difference for and forward differece for ).
Plus, I found the grid collapses when I set different angles (for example 90-degree (replace )).
Am I missing something in implementation?

I need your help.
Here is my code.
% Parameter settings
eta_max = 10;
xi_max = 10;
Delta_eta = 0.1;
Delta_xi = 0.1;
tol = 1e-6;
max_iterations = 100000;

% Grid size
eta_steps = floor(eta_max / Delta_eta) + 1;
xi_steps = floor(xi_max / Delta_xi) + 1;

% Initial conditions
x = zeros(eta_steps, xi_steps);
y = repmat((0:eta_steps-1)’ * Delta_eta, 1, xi_steps);

% Boundary conditions
x(1, 🙂 = linspace(0, xi_max, xi_steps);

% Finite difference method
converged = false;
iteration = 0;

while ~converged && iteration < max_iterations
iteration = iteration + 1;
max_error = 0;

for n = 1:eta_steps – 1
for m = 2:xi_steps – 1
x_xi = (x(n, m+1) – x(n, m-1)) / (2 * Delta_xi);
y_xi = (y(n, m+1) – y(n, m-1)) / (2 * Delta_xi);

new_x = x(n, m) + Delta_eta * ((pi/4) – y_xi)/(x_xi);
error_x = abs(new_x – x(n, m));
max_error = max([max_error, error_x]);

x(n + 1, m) = new_x;
end

x(n+1, xi_steps) = x(n+1, xi_steps-1) + Delta_xi;
x(n+1, 1) = x(n+1, 2) – Delta_xi;
end

if max_error < tol
converged = true;
end
end

% Plot the results
figure; hold on; axis equal; grid on;

for m = 1:xi_steps
plot(x(:, m), y(:, m), ‘r’);
end

for n = 1:eta_steps
plot(x(n, :), y(n, :), ‘b’);
end

title([‘Iterations until convergence: ‘, num2str(iteration)]);
xlabel(‘x’); ylabel(‘y’); Hi everyone,
I’m trying to generate a uniform grid where the red lines intersect at a 45-degree angle to the horizontal lines in blue using the finite difference method in MATLAB.
However, the resulting grid is slightly off, as shown in the attached image. Intesection angle is uniform but higher than 45-degree.
I set computational domain as and a grid is generated on physical domain with coordinates .
As I want to generate a mesh described above, I aimed to solve the following PDE :

where we have (horizontal lines). The boundary conditions are .
The above equation comes down to the following:

Based on the above equation, I discretized to finite difference form (central difference for and forward differece for ).
Plus, I found the grid collapses when I set different angles (for example 90-degree (replace )).
Am I missing something in implementation?

I need your help.
Here is my code.
% Parameter settings
eta_max = 10;
xi_max = 10;
Delta_eta = 0.1;
Delta_xi = 0.1;
tol = 1e-6;
max_iterations = 100000;

% Grid size
eta_steps = floor(eta_max / Delta_eta) + 1;
xi_steps = floor(xi_max / Delta_xi) + 1;

% Initial conditions
x = zeros(eta_steps, xi_steps);
y = repmat((0:eta_steps-1)’ * Delta_eta, 1, xi_steps);

% Boundary conditions
x(1, 🙂 = linspace(0, xi_max, xi_steps);

% Finite difference method
converged = false;
iteration = 0;

while ~converged && iteration < max_iterations
iteration = iteration + 1;
max_error = 0;

for n = 1:eta_steps – 1
for m = 2:xi_steps – 1
x_xi = (x(n, m+1) – x(n, m-1)) / (2 * Delta_xi);
y_xi = (y(n, m+1) – y(n, m-1)) / (2 * Delta_xi);

new_x = x(n, m) + Delta_eta * ((pi/4) – y_xi)/(x_xi);
error_x = abs(new_x – x(n, m));
max_error = max([max_error, error_x]);

x(n + 1, m) = new_x;
end

x(n+1, xi_steps) = x(n+1, xi_steps-1) + Delta_xi;
x(n+1, 1) = x(n+1, 2) – Delta_xi;
end

if max_error < tol
converged = true;
end
end

% Plot the results
figure; hold on; axis equal; grid on;

for m = 1:xi_steps
plot(x(:, m), y(:, m), ‘r’);
end

for n = 1:eta_steps
plot(x(n, :), y(n, :), ‘b’);
end

title([‘Iterations until convergence: ‘, num2str(iteration)]);
xlabel(‘x’); ylabel(‘y’); finite difference method, grid generation, mesh generation, numerical analysis, differential equations MATLAB Answers — New Questions

​

Tags: matlab

Share this!

Related posts

Generate ST code from a look-up table with CONSTANT attribute
2025-05-22

Generate ST code from a look-up table with CONSTANT attribute

“no healthy upstream” error when trying to access My Account
2025-05-22

“no healthy upstream” error when trying to access My Account

MATLAB Answers is provisionally back?
2025-05-21

MATLAB Answers is provisionally back?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Categories

  • Matlab
  • Microsoft
  • News
  • Other
Application Package Repository Telkom University

Tags

matlab microsoft opensources
Application Package Download License

Application Package Download License

Adobe
Google for Education
IBM
Matlab
Microsoft
Wordpress
Visual Paradigm
Opensource

Sign Up For Newsletters

Be the First to Know. Sign up for newsletter today

Application Package Repository Telkom University

Portal Application Package Repository Telkom University, for internal use only, empower civitas academica in study and research.

Information

  • Telkom University
  • About Us
  • Contact
  • Forum Discussion
  • FAQ
  • Helpdesk Ticket

Contact Us

  • Ask: Any question please read FAQ
  • Mail: [email protected]
  • Call: +62 823-1994-9941
  • WA: +62 823-1994-9943
  • Site: Gedung Panambulai. Jl. Telekomunikasi

Copyright © Telkom University. All Rights Reserved. ch

  • FAQ
  • Privacy Policy
  • Term

This Application Package for internal Telkom University only (students and employee). Chiers... Dismiss