Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Graph shows not all elemetns

조회 수: 1 (최근 30일)
Marcel Ziegler
Marcel Ziegler 2018년 6월 18일
마감: Marcel Ziegler 2018년 6월 19일
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
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일
I sugest
F_1 = temps(:,5.');
must be
F_1 = temps(:,5)';

Marcel Ziegler
Marcel Ziegler 2018년 6월 19일
편집: Marcel Ziegler 2018년 6월 19일
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...

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

Community Treasure Hunt

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

Start Hunting!

Translated by