Plot array of x ,y both in 2 columns, got unexpected multiple line result.

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

Alex Mcaulley
Alex Mcaulley il 19 Lug 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 Commenti
Alex Mcaulley
Alex Mcaulley il 19 Lug 2019
Sorry, but I don't know what is happening... Just a last try, what is the result of
findobj(gcf)
findall(gcf)
Tamura Kentai
Tamura Kentai il 19 Lug 2019
Hi, Alex:
The returned value is as below, all is numbers.
Thank you.
>> findobj(gcf)
ans =
1.0000
175.0510
176.0481
>> findall(gcf)
ans =
1.0000
175.0510
146.0461
134.0461
133.0461
82.0461
66.0461
59.0461
39.0461
20.0461
2.0468
179.0450
178.0461
177.0461
176.0481
174.0466
173.0461
172.0461
171.0461
170.0461
167.0461
166.0461
165.0461
151.0461
150.0461
149.0461
148.0461
147.0461
145.0461
144.0461
143.0461
142.0461
141.0461
140.0461
139.0461
138.0461
137.0461
136.0461
135.0461
132.0461
131.0461
122.0461
113.0461
106.0461
105.0461
104.0461
103.0461
102.0461
101.0461
92.0461
91.0461
90.0461
89.0461
88.0461
87.0461
86.0461
85.0461
84.0461
83.0461
81.0461
80.0461
79.0461
78.0461
77.0461
76.0461
75.0461
74.0461
73.0461
72.0461
71.0461
70.0461
69.0461
68.0461
67.0461
65.0461
64.0461
63.0461
62.0461
61.0461
60.0461
58.0461
57.0461
56.0461
55.0461
54.0461
53.0461
52.0461
51.0461
50.0461
49.0461
48.0461
47.0461
46.0461
45.0461
44.0461
43.0461
42.0461
41.0461
40.0461
38.0461
37.0461
36.0461
35.0461
34.0461
33.0461
32.0461
31.0461
30.0461
29.0461
28.0461
27.0461
21.0461
19.0461
18.0461
17.0461
16.0461
15.0461
13.0461
12.0461
11.0461
10.0461
9.0461
8.0461
7.0461
6.0461
5.0461
4.0461
3.0461
169.0461
168.0461
164.0461
163.0461
162.0461
161.0461
160.0461
159.0461
158.0461
157.0461
156.0461
155.0461
154.0461
153.0461
152.0461
130.0461
129.0461
128.0461
127.0461
126.0461
123.0461
121.0461
120.0461
119.0461
118.0461
117.0461
116.0461
115.0461
114.0461
112.0461
111.0461
110.0461
109.0461
108.0461
107.0461
100.0461
99.0461
98.0461
97.0461
96.0461
95.0461
94.0461
93.0461
26.0461
25.0461
24.0461
23.0461
22.0461
14.0461
125.0461
124.0461

Accedi per commentare.

Più risposte (1)

Tamura Kentai
Tamura Kentai il 19 Lug 2019
Hi, :
I guess , get(h) will help to show more...under the 'figure 1' still opened.
>> get(h)
DisplayName: ''
Annotation: [1x1 hg.Annotation]
Color: [0 0 1]
LineStyle: '-'
LineWidth: 0.5000
Marker: 'none'
MarkerSize: 6
MarkerEdgeColor: 'auto'
MarkerFaceColor: 'none'
XData: [1x701 double]
YData: [1x701 double]
ZData: [1x0 double]
BeingDeleted: 'off'
ButtonDownFcn: []
Children: [0x1 double]
Clipping: 'on'
CreateFcn: []
DeleteFcn: []
BusyAction: 'queue'
HandleVisibility: 'on'
HitTest: 'on'
Interruptible: 'on'
Selected: 'off'
SelectionHighlight: 'on'
Tag: ''
Type: 'line'
UIContextMenu: []
UserData: []
Visible: 'on'
Parent: 173.0046
XDataMode: 'manual'
XDataSource: ''
YDataSource: ''
ZDataSource: ''

Categorie

Scopri di più su Graphics Object Properties in Help Center e File Exchange

Tag

Non è stata ancora inserito alcun tag.

Prodotti


Release

R2013b

Community Treasure Hunt

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

Start Hunting!

Translated by