Why am I getting this error : "Warning: Imaginary parts of complex X and/or Y arguments ignored " .

4 Ansichten (letzte 30 Tage)
close all;
clc;
t = (0:pi/3:2*pi);
r = 2;
cx = r*sqrt(3)*cos(pi/2+1i*pi/3);
cy = r*sqrt(3)*sin(pi/2+1i*pi/3);
ax = cx+r*cos(t);
ay = cy+r*sin(t);
plot(ax,ay);
Warning: Imaginary parts of complex X and/or Y arguments ignored.
grid on;
for i=0:6
cx = r*sqrt(3)*cos(pi/2+1i*pi/3);
cy = r*sqrt(3)*sin(pi/2+1i*pi/3);
ax = cx+r*cos(t);
ay = cy+r*sin(t);
plot(ax,ay);
hold on;
plot(-9+ax, ay-1.8);
hold on;
plot(9+ax, ay+1.8);
hold on;
plot(6-ax,ay-6.9);
grid on;
text(-0.2,0,'A');
text(-0.2,3.5,'B');
text(-3.2,1.75,'C');
text(-3.2,-1.75,'D');
text(-0.2,-3.5,'E');
text(2.8,-1.75,'F');
text(2.8,1.75,'G');
text(5.8,-7,'A');
text(5.8,-3.5,'B');
text(2.8,-5.3,'C');
text(2.8,-8.75,'D');
text(5.8,-10.5,'E');
text(8.8,-8.75,'F');
text(8.8,-5.25,'G');
text(8.8,1.75,'A');
text(8.8,5.25,'B');
text(5.8,3.45,'C');
text(5.8,0,'D');
text(8.8,-1.75,'E');
text(11.8,0,'F');
text(11.8,3.5,'G');
text(-9.2,-1.75,'A');
text(-9.2,1.75,'B');
text(-12.2,0,'C');
text(-12.2,-3,5,'D');
text(-9.2,-5.3,'E');
text(-6.2,-3.5,'F');
text(-6.2,0,'G');
end
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.

Antworten (2)

Cris LaPierre
Cris LaPierre am 19 Okt. 2021
Because you are trying to plot complex values on cartesian axes. You create cx and cy as complex numbers
% vv imaginary
cx = r*sqrt(3)*cos(pi/2+1i*pi/3);
cy = r*sqrt(3)*sin(pi/2+1i*pi/3);
% ^^ imaginary
You might look into the functions real, imag, and abs depending what it is you want to view.

yanqi liu
yanqi liu am 27 Okt. 2021
sir,use
warning off all

Community Treasure Hunt

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

Start Hunting!

Translated by