how do I plot input / output data so as to have a continuous bar in that range and not two simple points for each output / input?
Ältere Kommentare anzeigen
Hello everyone! I have the following datetime vector, which contains the time (date and time) in which the patient has been away from home. The odd rows correspond to the moment he left the house, the even rows correspond to the moment he returned home. How do I make a horizontal bar graph in which there is time in the x axis and my vector in the y axis, so as to obtain continuous bars for the "out-entered" time intervals (in red in the figure)? Thanks in advance.

3 Kommentare
jonas
am 6 Aug. 2018
I don't understand what you mean. Can you draw a sketch by hand?
Erica Corradi
am 6 Aug. 2018
jonas
am 6 Aug. 2018
Does it have to be a bar graph? You can make a stacked horizontal bar with barh, but it's extremely slow. You could get similar results using plot, which would be much more effecient.
Akzeptierte Antwort
Weitere Antworten (1)
Erica Corradi
am 10 Aug. 2018
0 Stimmen
5 Kommentare
jonas
am 10 Aug. 2018
What do you mean put together? I never understood what pir_tab_night is, so I cannot answer that.
You can change the y-position of the alarms. It's right in this line
y2=mean(y1(:))-0.3
just change the value of -0.3 (currently set to 0.3 below the bar)
Erica Corradi
am 10 Aug. 2018
jonas
am 10 Aug. 2018
And what do you want each segment of the bar to represent? In the first one you have open/close. In the other one you just have a single time-series. Draw another picture?
Erica Corradi
am 10 Aug. 2018
Okay, I kind of get it. In the closing_opening you have a green bar when the person is away (if I remember correctly). In the other one, you have a bunch of time-slots with different sensor names. As the code is written now, the time between those slots are marked in different colors. Sometimes there is a big gap in the pir-time-series, I assume this means the person is away from home?
Obvious solution is to concatenate both data sets into a single large timetable, with a special identifier for closing_opening. I've done this, and it looks quite OK. If my understanding is correct, this situation should never occur:
subject leaves
motion detected
subject returns
In fact, subject leaves should always be followed by subject returns, with no motion detected in between. I've checked the combined timetable and it looks OK so far (open_closing always occur in pairs).
But what about this sequence:
12-Mar-2018 06:59:55 dbuid-17
12-Mar-2018 06:59:58 dbuid-19
12-Mar-2018 09:57:47 open_close
12-Mar-2018 11:09:40 open_close
12-Mar-2018 13:45:31 open_close
12-Mar-2018 15:50:14 open_close
12-Mar-2018 21:02:31 dbuid-19
12-Mar-2018 21:02:36 dbuid-19
12-Mar-2018 21:02:40 dbuid-19
It seems motion is detected - subject leaves - subject comes back - subject leaves - subject comes back - motion detected 6 hours later. I don't know what this means, but be cautious with the interpretation.
Attached is a code you can start from. It will give you something similar to what you drew. Since the data set is now so large, there is no chance for me to check if it's correct.
I'll consider this closed now. If you have any other question, please post a new submission and make sure the problem is well stated. General advice: don't throw a bunch of data on someone who is trying to help with the technical aspects of MATLAB. Make it easy by condensing the data set down to a few lines.
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!