Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Graph shows not all elemetns

1 Ansicht (letzte 30 Tage)
Marcel Ziegler
Marcel Ziegler am 18 Jun. 2018
Geschlossen: Marcel Ziegler am 19 Jun. 2018
I read a csv-file to get my vectors. All of them have 9152 data elements. They are signals of a osziloskop.
temps = xlsread('Test_100mms');
v_1 = temps(:,2).';
F_1 = temps(:,5.');
I_1 = temps(:,8).';
s_1 = temps(:,11).';
After that i want to plot them into a graph:
figure;
hold on;
plot(v_1,'m','LineWidth',1);
plot(F_1,'r','LineWidth',1);
plot(I_1,'b','LineWidth',1);
plot(s_1,'k-o','LineWidth',1);
plot(s_1,'g','LineWidth',1);
legend('data1','data2','data3','data4');
ylabel('Messwerte');
xlabel('Zeit t in ms');
set(gca,'FontSize',18)
grid;
When i saw the graph, i recogniced that some data points are missing. To illustrate i plotted the 4rd signal, s_1, twice:
  • first with no styles or markers plot(s_1,'g','LineWidth',1);
  • secondly with markers plot(s_1,'k-o','LineWidth',1);
the first graph displays only a few data points. The second graph shows all data points. The only difference in my code is the "-o". You can see that in the picture of the graph.
My first guess was that Matalb leaves some data points away to save memory or compute time. Maybe i should mention that this plot is one of about 20 plots and i use a live script.
  8 Kommentare
Guillaume
Guillaume am 19 Jun. 2018
Marcel closed the question with the comment:
I solved it by myself. I used later in the script a function which reduced the data points of all plots, not like I wanted.
dpb
dpb am 19 Jun. 2018
Ah! Knew just had to be something of the sort; there are all kinds of differing X|YData lengths in the attached figure--
>> for i=1:5,hL(i),end
ans =
Line (data5) with properties:
Color: [0 1 0]
LineStyle: '-'
LineWidth: 1
Marker: 'none'
MarkerSize: 6
MarkerFaceColor: 'none'
XData: [1 128 4527 4724 8192]
YData: [14.9663 6.0100 -425.0042 -417.9047 -71.1192]
ZData: [1×0 double]
Show all properties
ans =
Line (data4) with properties:
Color: [0 0 0]
LineStyle: '-'
LineWidth: 1
Marker: 'o'
MarkerSize: 6
MarkerFaceColor: 'none'
XData: [1×8192 double]
YData: [1×8192 double]
ZData: [1×0 double]
Show all properties
ans =
Line (data3) with properties:
Color: [0 0 1]
LineStyle: '-'
LineWidth: 1
Marker: 'none'
MarkerSize: 6
MarkerFaceColor: 'none'
XData: [1 493 1152 1546 2543 4618 4946 5630 8192]
YData: [-0.2180 -0.2790 -0.2370 -0.2500 -0.6490 0.5180 0.4300 0.0530 0.1110]
ZData: [1×0 double]
Show all properties
ans =
Line (data2) with properties:
Color: [1 0 0]
LineStyle: '-'
LineWidth: 1
Marker: 'none'
MarkerSize: 6
MarkerFaceColor: 'none'
XData: [1×368 double]
YData: [1×368 double]
ZData: [1×0 double]
Show all properties
ans =
Line (data1) with properties:
Color: [1 0 1]
LineStyle: '-'
LineWidth: 1
Marker: 'none'
MarkerSize: 6
MarkerFaceColor: 'none'
XData: [1×71 double]
YData: [1×71 double]
ZData: [1×0 double]
Show all properties
>>
So for each of the five lines the length was respectively
5, 8192, 9, 368, 71
I don't know how live scripts are updated or just what Marcel did at the keyboard that isn't reflected in the script source code, but something certainly changed the lengths of the data vectors as each was plotted.

Antworten (2)

Sayyed Ahmad
Sayyed Ahmad am 19 Jun. 2018
I sugest
F_1 = temps(:,5.');
must be
F_1 = temps(:,5)';

Marcel Ziegler
Marcel Ziegler am 19 Jun. 2018
Bearbeitet: Marcel Ziegler am 19 Jun. 2018
Thanks for your time. I went back to university and asked my prof. And after 1 hour we found the solutuion. In the main script i used matlab2tikz and cleanfigure to get as much as possible graphs into latex. Cleanfigure must change variables globaly for the editor. So i got the "bug" even atfer i copyed the figure with the plots into a seperate script after i run cleanfigure. After removing cleanfigure, restart matlab, i got no problems.
  1 Kommentar
dpb
dpb am 19 Jun. 2018
AHA! Just knew had to be something else going on than was apparent! :)
Thanks for the update; always appreciated when get strange symptoms resolved both for our curiosity who responded as well as is beneficial in future if some other poor soul stumbles upon the thread isn't left hanging...

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by