Plotting In Matlab with three columns?

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.

 采纳的回答

Stephen23
Stephen23 2019-2-24
编辑:Stephen23 2019-2-24
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 个评论

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.
"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?
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.
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

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Statics and Dynamics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by