Plot array of x ,y both in 2 columns, got unexpected multiple line result.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Tamura Kentai
le 19 Juil 2019
Réponse apportée : Tamura Kentai
le 19 Juil 2019
Hi, :
I beg your pardon, I got some unexpected result of plot number of line. I have uploaded the .mat files which contained the x,y axes data.
The code is as below:
% plot_array_result_in_multiple_line.m
load('X.mat','X');
load('Y.mat','Y');
plot(log10(X(:,1)),20*log10(hypot(Y(:,1),Y(:,2))));
title( ['Plot Bode']);
xlabel( 'x=Freq-axis (in 10^n)') , ylabel( 'y=data value-axis (in dB)' );
grid on;
But I get 3 lines on the plot figure, as I expect to be only one. One is possible because of the hypot(), root of square , but there is another one (the lowest one) I thought it's very strange, its y-values seems same as reciprocal of x-values, Can anyone know why does it plot this ? And how to fix it ?
Thank you very much.
0 commentaires
Réponse acceptée
Alex Mcaulley
le 19 Juil 2019
Just one line is ploted. See this:
% plot_array_result_in_multiple_line.m
load('X.mat','X');
load('Y.mat','Y');
h = plot(log10(X(:,1)),20*log10(hypot(Y(:,1),Y(:,2))));
title( ['Plot Bode']);
xlabel( 'x=Freq-axis (in 10^n)') , ylabel( 'y=data value-axis (in dB)' );
grid on;
findobj(h)
ans =
Line with properties:
Color: [0 0.4470 0.7410]
LineStyle: '-'
LineWidth: 0.5000
Marker: 'none'
MarkerSize: 6
MarkerFaceColor: 'none'
XData: [1×3505 double]
YData: [1×3505 double]
ZData: [1×0 double]
Show all properties
The problem is that you have repeated X(1) values (i.e. X(371) == X(1773)), but the corresponding Y are different. For that reason you get "unexpected results".
8 commentaires
Alex Mcaulley
le 19 Juil 2019
Sorry, but I don't know what is happening... Just a last try, what is the result of
findobj(gcf)
findall(gcf)
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Graphics Object Properties dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!