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

3 vues (au cours des 30 derniers jours)
Shayla Merrigan
Shayla Merrigan le 19 Juin 2022
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');

Réponses (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 19 Juin 2022
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.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by