Plot array of x ,y both in 2 columns, got unexpected multiple line result.
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Alex Mcaulley
2019 年 7 月 19 日
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 件のコメント
Alex Mcaulley
2019 年 7 月 19 日
Sorry, but I don't know what is happening... Just a last try, what is the result of
findobj(gcf)
findall(gcf)
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Graphics Object Properties についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!