I want to plot the Global_X column on Y-axis and Plot_Time on X-axis for the CSV file attached. However, I am intereseted in plotting unique subplots based on vehicle ID. For example, there should be a plot(preferably represented by line) for Vehicle_ID 65 and different one for Vehicle_ID 66. This should repeat until all the plots are completed for each Vehicle_ID. I am trying to have the plots for all the vehicle_Ids on the same big plot. I would really appreciate the help.

 Akzeptierte Antwort

Stephen23
Stephen23 am 24 Feb. 2019
Bearbeitet: Stephen23 am 24 Feb. 2019

1 Stimme

M = csvread('Query_version.csv',1,0);
U = unique(M(:,1));
N = numel(U);
C = cell(2,N);
for k = 1:numel(U)
X = M(:,1)==U(k);
C{1,k} = M(X,2);
C{2,k} = M(X,3);
end
plot(C{:})
Giving all 449 different lines, one for each ID:
Query.png
It is not clear how you want to distinguish between 449 different lines on one plot.

4 Kommentare

Gaurav Kashyap
Gaurav Kashyap am 24 Feb. 2019
Thanks a lot for the assistance. Is there a way I can have three plots? 0-300, 300-600 and above 600 being three of the ranges. The reason why I am looking at have all these plots together is study the vehicle trajectory.
Stephen23
Stephen23 am 24 Feb. 2019
"Is there a way I can have three plots?"
Probably.
"...0-300, 300-600 and above 600 being three of the ranges."
Of which variable?
Gaurav Kashyap
Gaurav Kashyap am 24 Feb. 2019
The ranges are for the variable Plot_Time. This way I can look at the vehicle trajectory data on three different plots. Thanks a lot for the help.
Stephen23
Stephen23 am 25 Feb. 2019
M = csvread('Query_version.csv',1,0);
V = [0,300,600,Inf];
[~,B] = histc(M(:,2),V);
U = unique(M(:,1));
C = cell(2,numel(U),numel(V)-1);
S = size(C);
for ii = 1:S(2)
X = M(:,1)==U(ii);
for jj = 1:S(3)
Y = B==jj;
C{1,ii,jj} = M(X&Y,2);
C{2,ii,jj} = M(X&Y,3);
end
end
subplot(3,1,1)
plot(C{:,:,1})
subplot(3,1,2)
plot(C{:,:,2})
subplot(3,1,3)
plot(C{:,:,3})
Giving (you can adjust the figure size, etc.):
Query.png

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by