Warning: Imaginary parts of complex X and/or Y arguments ignored.

조회 수: 3 (최근 30일)
Shayla Merrigan
Shayla Merrigan 2022년 6월 19일
답변: Sulaymon Eshkabilov 2022년 6월 19일
In the higlighted, underlined, bolded line there is an issue that I can't seem to figure out why it keeps saying "Warning: Imaginary parts of complex X and/or Y arguments ignored."
% 100 Gaussian Normal distributed random numbers
xi = 1 + 1.9*randn(100,1);
yi = 3 + rands(100,1);
% Parameters
param.P = 0.9; % 90% Error ellipse
param.option = 'Prob';
param.Dec = 200; %200 points of error ellipse
[a,b,amean,bmean] = ErrorEllipse2D(xi,yi,param);
figure('NumberTitle','off','Name','Error Ellipse');
plot(a,b,'Color','blue');
grid on;
hold on;
axis equal;
plot(xi,yi,'Marker','+','LineStyle','none');
plot(amean,bmean,'Marker','o','MarkerFaceColor','black','LineStyle','none','color','black');
title('Gaussian random numbers centered at [1,3]')
xlabel('x - numbers');
ylabel('y - numbers');

답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2022년 6월 19일
from your problem statement, your calculation results a, b and amean, bmean contain some complex values. Thus, plot() fcn plots only real parts of their values. If you want to plot real parts of a vs. b and amean vs. bmean, and imaginary of ab vs. b, and amean vs. bmean, that can be attained with the followings:
...
figure('NumberTitle','off','Name','Error Ellipse');
yyaxis left
plot(real(a),real(b),'Color','blue'); % Real part of a and b
yyaxis right
plot(imag(a),imag(b),'Color','red'); % Imag. part of a and b
grid on;
hold on;
axis equal;
yyaxis left
plot(xi,yi,'Marker','+','LineStyle','none');
plot(real(amean),real(bmean),'Marker','o','MarkerFaceColor','black','LineStyle','none','color','black');
ylabel('Real part of y - numbers');
yyaxis right
plot(imag(amean),imag(bmean),'Marker','*','MarkerFaceColor','red','LineStyle','none','color','red');
title('Gaussian random numbers centered at [1,3]')
xlabel('x - numbers');
ylabel('Imag. part of y - numbers');
% etc.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by