필터 지우기
필터 지우기

Plotting and labelling without repetition a scatter /line plot in matlab.

조회 수: 1 (최근 30일)
avantika
avantika 2013년 9월 4일
hi!
I am trying to plot and label line/scatter plot of two columns in a dataset , the first column are the time values to be plotted on x - axis and the corresponding pitch values are in the second column of the dataset to be plotted on the y-axis. The labels for each point are in third column of the dataset labelled as notation. The labels should be added as such only the first value of repeated entries should be taken as label. The columns of dataset are 'char' array and the length of dataset is x 6839*3. An example of dataset is given below:
Time Pitch notation
2.64 329.63 'GM'
2.64 329.63 'GM'
3.49 261.63 'SM'
4.09 349.23 'MM'
6.27 261.63 'SM'
6.50 349.23 'MM'
6.72 329.63 'GM'
6.75 349.23 'MM'
7.02 329.63 'GM'
7.28 349.23 'MM'
7.32 329.63 'GM'
8.06 261.63 'SM'
8.44 329.63 'GM'
9.36 261.63 'SM'
9.95 349.23 'MM'
11.81 329.63 'GM'
12.04 246.94 'NL'
12.09 261.63 'SM'
12.29 329.63 'GM'
when i use the following commands , i do get a graph with labels but repeated entries are not removed as of now: ds = dataset('XLSFile', 'Deshgatannotation.xlsx','sheet', 2);
figure
time = ds(:,1);
pitch = ds(:,2);
l = cellstr(ds(:,3));
plot(time, pitch,'.','color','r')
text(double(time), double(pitch), l,'fontsize',6, 'color','b','rotation',45,'horizontal','left', 'vertical','bottom');
xlabel('time');
ylabel('notation');
title('notations vs time')
  댓글 수: 3
avantika
avantika 2013년 9월 5일
Hi! Yes i want the latter thing to happen i.e. only remove the case where there are two (or more) of the same ID in sequence and start again w/ the next different ID.
Using the following command gives an error message:
ids=[true ~strcmp(l(2:end),l(1:end-1))];
Error using horzcat
Dimensions of matrices being concatenated are not consistent
dpb
dpb 2013년 9월 5일
편집: dpb 2013년 9월 5일
You have row or column vector? I presumed row above; if column either use
ids=[true; ~strcmp(l(2:end),l(1:end-1))]; % column vector result
or
ids=[true ~strcmp(l(2:end),l(1:end-1))']; % row result of input column
Have to either add a row or a column depending on which direction the label list is oriented or reorient the list to make the concatenation commensurate in dimensions. Which way specifically is dependent on your input direction and desired output.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by