Info

この質問は閉じられています。 編集または回答するには再度開いてください。

how can i plot the following text files?

1 回表示 (過去 30 日間)
ciaran balfe
ciaran balfe 2019 年 3 月 15 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
im trying to plot the textfiles attached like the image attached, can anyone help me please?
car velocity lane 1, 50 cars.PNG

回答 (3 件)

Sajeer Modavan
Sajeer Modavan 2019 年 3 月 16 日
Input1 = load('double_lane_velocity_lane1.txt');
Input2 = load('double_lane_velocity_lane2.txt');
figure
for ii = 0:49
index1 = find(Input1(:,1)==ii);
index2 = find(Input2(:,1)==ii);
t = [Input1(index1,2); Input2(index2,2)];
In = [Input1(index1,3); Input2(index2,3)];
plot(t,In),hold on
end
ylim([18 41])
xlabel('Simulation Time (s)')
ylabel('velocity (m/s)')

ciaran balfe
ciaran balfe 2019 年 3 月 17 日
thanks very much, is there anyway to graph each text file seperately? double_lane_velocity_lane1 is what you have graphed and it does look exactly as it is meant to but double_lane_velocity_lane2 looks a little different.
also ive attached another two text files i was wondering if you could tell me why your code doesnt work for these? thank you very much i appreciate your help

Sajeer Modavan
Sajeer Modavan 2019 年 3 月 17 日
編集済み: Sajeer Modavan 2019 年 3 月 17 日
For plotting combined input 1 and 2
clear, clc, close all;
Input1 = load('double_lane_position_lane12k.txt');
Input2 = load('double_lane_position_lane22k.txt');
fig = figure;
for ii = 0:49
index1 = find(Input1(:,1)==ii);
index2 = find(Input2(:,1)==ii);
t = [Input1(index1,2); Input2(index2,2)];
In = [Input1(index1,3); Input2(index2,3)];
plot(t,In),hold on
end
xlabel('Simulation Time (s)')
ylabel('velocity (m/s)')
you can edith this code for plotting input 1 and 2 seperate
  1 件のコメント
Sajeer Modavan
Sajeer Modavan 2019 年 3 月 24 日
Do you need any further help, accept the answer and close this issue if you don't need any further help.

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by