Graph shows not all elemetns

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

dpb
dpb 2018년 6월 18일
The figure couldn't have been generated from the shown code in isolation; there's neither an x variable to have plotted versus anything other than the element ordinal value and the second plot command would replace the previous lacking a hold on
Can't diagnose what we can't see, but the conclusion that must be drawn is there were only a few points in the array at the time the green trace was actually drawn vis a vis the black.
Post a COMPLETE example that illustrates the issue from a bare figure; I strongly suspect while trying to do that you'll uncover the cause of your above symptom.
Also, save Figure as .jpg and attach instead of humongous bitmap; the attachment doesn't even show the full figure.
Marcel Ziegler
Marcel Ziegler 2018년 6월 18일
I editted my post with the full code.
dpb
dpb 2018년 6월 18일
편집: dpb 2018년 6월 19일
We don't have the data to try to duplicate identically (you could attach .mat file with it) but I can't create such a symptom here.
What if you use
hL(1)=plot(v_1,'m','LineWidth',1);
hL(2)=plot(F_1,'r','LineWidth',1);
hL(3)=plot(I_1,'b','LineWidth',1);
hL(4)=plot(s_1,'k-o','LineWidth',1);
hL(5)=plot(s_1,'g','LineWidth',1);
and then
hL(4)
hL(5)
at command line?
I suppose it would be worth asking which Release you're using.
I'm currently at R2017b but have been ML user since Release 3 back in the 1980s and I've never seen such a behavior.
ADDENDUM I've also never used a live script, don't really know what they are even in any detail; try the same exercise in a regular .m file. I guess that'd be my first guess as to what might be trying to be "clever".
Greg
Greg 2018년 6월 19일
I see no missing data points in the attached .fig file. The green line and black markers trace out the exact same path.
What do you think they should look like that makes you say data points are missing?
Marcel Ziegler
Marcel Ziegler 2018년 6월 19일
I added a picture, where you can see that it is not the case in my code.
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 2018년 6월 19일
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 2018년 6월 19일
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.

답변 (2개)

Sayyed Ahmad
Sayyed Ahmad 2018년 6월 19일

0 개 추천

I sugest
F_1 = temps(:,5.');
must be
F_1 = temps(:,5)';
Marcel Ziegler
Marcel Ziegler 2018년 6월 19일
편집: Marcel Ziegler 2018년 6월 19일

0 개 추천

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

dpb
dpb 2018년 6월 19일
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...

이 질문은 마감되었습니다.

질문:

2018년 6월 18일

마감:

2018년 6월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by