How do I plot multiple, disparate lines onto one graph showing changes between 2 conditions?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Brady DeCouto
am 28 Feb. 2019
Kommentiert: Bob Thompson
am 28 Feb. 2019
Hello,
I am analyzing balance data, and there are 2 conditions and 5 subjects. I want to plot each subject as a line onto one graph, where condition 1 and condition 2 are on the x-axis, and sway values are on the y-axis (so I can see change between conditions for each subject). I am using a data sheet, and have tried the following syntax:
plot(categorical(date.Condition),date.PosturalSway_Acc_CentroidalFrequency_Coronal__Hz_)
The following figure comes out:
![Untitled.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/206305/Untitled.png)
This is obviously messy. I want individual lines for each subject (not connecting every point). Is there any simple code that can accomplish this?
Thanks,
B
0 Kommentare
Akzeptierte Antwort
Bob Thompson
am 28 Feb. 2019
I would suggest a quick loop through each of your subjects. You can keep multiple lines on a single plot by using the hold command.
figure(1)
hold on
for i = 1:...
plot(...)
end
4 Kommentare
Bob Thompson
am 28 Feb. 2019
I'm not sure if that's it or not. A quick way to check these types of things is to grab parts of your command and put them in the command line. If you get the same error then you know what portion is causing the error. It might actually be 'categorical(date.Condition)(i*2-1:i*2)' because you're trying to take the index of the result of categorical() rather than of the date.Condition protion. If this does reproduce the error then move your indexing inside the categorical() command call.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!