Create a 2D grid to map points over a transformation?

11 Ansichten (letzte 30 Tage)
Shovnik Paul
Shovnik Paul am 10 Feb. 2022
Beantwortet: Pratyush Swain am 20 Mär. 2025
I am trying to create two plots: one showing a grid on the top and the second showing a transformation applied to every point on the grid (bottom). Till now I have been able to figure out the following way which only works when the x and y ranges are symmetric:
x = linspace(-5, 5, 10);
y = linspace(-5, 5, 100);
[X, Y]= meshgrid(x, y);
figure
plot(X, Y, 'blue', Y, X, 'blue');
Z = X + i*Y;
W = Z.^2; % f(z) = z^2 for example
figure
plot(W, 'blue')
Z = Y + i*X;
W = Z.^2;
hold on;
plot(W, 'blue')
So far so good but say I want to create grid that is asymetrical with regards to the axes ranges. For example, the normalized impedance of a transmission line z = r + ix which can only have positive resistance r. Say want a grid in the region 0 < r < 10 and -10 < x < 10 with lines at intervals of 1 say. Is there a general way of doing this? (and perhas a better way of doing the above?)

Antworten (1)

Pratyush Swain
Pratyush Swain am 20 Mär. 2025
Hi Shovnik,
For handling assymmetric grid ranges we can utilize a general approach as follows:
% Set up the assymmetric ranges %
r = linspace(0, 10, 11);
x = linspace(-10, 10, 21);
[R, X] = meshgrid(r, x);
% Convert to complex domain and apply conformal map %
Z = R + j*X;
W = Z.^2;
For plotting the original and transformed grid:
% Plotting horizontal and vertical lines separately %
figure;
plot(R, X, 'b');
hold on;
plot(R', X', 'b');
axis equal;
title('Original Grid');
% Instead of plotting plot(W), plotting row and column lines %
figure;
plot(real(W), imag(W), 'b'); hold on;
plot(real(W'), imag(W'), 'b');
axis equal;
title('Transformed Grid');
I have utilised the real function: https://www.mathworks.com/help/symbolic/sym.real.html and imag function: https://ww.mathworks.com/help/symbolic/sym.imag.html from the symbolic math toolbox.
Hope this helps.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by