how to write this code?

Hey,
Can someone help me to write a code that that:
Writes the line of the complex plane formed by the point z when the complex number z^2 moves along the sides of the square whose vertices are located at the points -1-i, 2-i, 2+2*i and -1 + 2*i. In the same figure, write a line formed by points z^2, whose arcs are the same color as the corresponding side of the square.
I made the square but can`t figure out how to get the curved lines.
Thanks for the help!

4 个评论

x1 = (-1 - i);
x2 = 2 - i;
x3 = 2 + 2*i;
x4 = -1 + 2*i;
t = linspace(0, 1, 100);
z1 = (1 - t) * x1 + t * x2;
z2 = (1 - t) * x2 + t * x3;
z3 = (1 - t) * x3 + t * x4;
z4 = (1 - t) * x4 + t * x1;
z = x1.^2;
figure
hold on
plot(real(z1), imag(z1), '--r')
plot(real(z2), imag(z2), '--g')
plot(real(z3), imag(z3), '--m')
plot(real(z4), imag(z4), '--b')
plot(real(x1), imag(x1), 'ok')
plot(real(x2), imag(x2), 'ok')
plot(real(x3), imag(x3), 'ok')
plot(real(x4), imag(x4), 'ok')
plot(real(z), imag(z), '-c')
axis equal
ax = gca;
ax.XAxisLocation = 'origin';
ax.YAxisLocation = 'origin';
xticks(-5:1:5)
yticks(-5:1:5)
xlabel('Real');
ylabel('Imag');
legend('Square', 'z^2');
xlim([-5, 5]);
ylim([-5, 5]);
axis equal;
This is what i have so far
You must square the sides of the square, not only its corner points:
z1_squared = z1.^2;
plot(real(z1_squared),imag(z1_squared))
Thank you very very much!!

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Line Plots 的更多信息

提问:

2022-12-18

评论:

2022-12-18

Community Treasure Hunt

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

Start Hunting!

Translated by