MATLAB Answers

Info

This question is closed.

Graph shows not all elemetns

1 view (last 30 days)
Marcel Ziegler
Marcel Ziegler on 18 Jun 2018
Closed: Marcel Ziegler on 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 Comments

Show 5 older comments
Guillaume
Guillaume on 19 Jun 2018
If you zoom in on the lower part of the graph. Is there still a discrepency?
If you change renderer, does the problem persist?
set(gcf, 'Renderer', 'painters');
Guillaume
Guillaume on 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 on 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.

Answers (2)

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

  0 Comments


Marcel Ziegler
Marcel Ziegler on 19 Jun 2018
Edited: Marcel Ziegler on 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 Comment

dpb
dpb on 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...

Translated by