How to plot temporal changes in batches of data?

조회 수: 2 (최근 30일)
David Crowe
David Crowe 2018년 6월 12일
댓글: David Crowe 2018년 6월 13일
Hello! I have a CSV file with the following example content:
SSID,RSS,Unit,Time,Batch
AP1,-40,dBm,11:11:11,0
AP2,-44,dBm,11:11:11,0
AP3,-90,dBm,11:11:11,0
AP1,-50,dBm,13:30:00,1
AP2,-66,dBm,13:30:00,1
AP3,-20,dBm,13:30:00,1
AP1,-2,dBm,15:00:00,2
AP2,-30,dBm,15:00:00,2
AP3,-40,dBm,15:00:00,2
And I'm wanting to plot each of the SSIDs with their RSS (received signal strength) with respect to its batch.
So far, I've tried plotting each of the RSS for each batch and get the following figure:
However, my goal is to connect these lines in a distinct way to show their temporal trend, like so:
Any pointers on how this might be done?

채택된 답변

dpb
dpb 2018년 6월 13일
편집: dpb 2018년 6월 13일
t=readtable('crowe.csv');
t.SSID=categorical(t.SSID);
t.Time=datetime(t.Time);
figure,hold on
[g,ids]=findgroups(t.SSID);
splitapply(@(x,y) plot(x,y,'o-'),t.Time,t.RSS,g);
legend(categories(ids),'location','best')
gives
  댓글 수: 1
David Crowe
David Crowe 2018년 6월 13일
This is perfect, dpb! I appreciate using the time data as well. Many thanks for your timely response.

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

추가 답변 (1개)

Kelly Kearney
Kelly Kearney 2018년 6월 12일
Assuming your file is read into a table array, I think the quickest way to do this is to unstack the SSID data and then plot:
tbl = readtable('data.csv');
tblu = unstack(tbl, 'RSS', 'SSID');
plot(tblu.Batch, [tblu.AP1 tblu.AP2 tblu.AP3]);
Depending on the number of unique SSIDs, you may prefer to concatenate the unstacked values programmatically, but here I simply typed it manually.
  댓글 수: 1
David Crowe
David Crowe 2018년 6월 13일
I had no idea about unstacking, thanks for the help Kelly!

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

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by