trouble plotting driving style from acceleration
Show older comments
clc;
clear all;
Mydata2=xlsread('Log_U0006387_160311_740d0.csv');
t=Mydata2(:,1);
v=Mydata2(:,3)*1.60934*1000/3600;
a = diff(v)./diff(t)
diff(v);
if a <0
a=inv(a); %To receive positive values for acceleration
end
if a < 0.7
ds_mapping = 0
end
for i = 1:length(a)
if a(i) >= 0.7
ds_mapping = 1;
elseif a <= 2.81
ds_mapping = 2;
elseif a <= 3.65
ds_mapping = 3;
end
end
yyaxis left
plot(t(2:end),a , 'r')
xlabel('time')
ylabel('Acceleration');
hold on
yyaxis right
plot(t(2:end),ds_mapping , 'b')
ylabel('DS');
hold off
grid on
this is the code I currently have i'm trying to plot the driving style between those ranges however, my answer keeps returning to zero
5 Comments
Dyuman Joshi
on 4 Aug 2023
1 - You need to store ds_mapping as a vector.
2 - Why are you comparing a vector against a scalar?
if a <0
%
if a < 0.7
3 - Why are you taking inverse of a vector?
a=inv(a); %To receive positive values for acceleration
Did you want to get the absolute value of real numbers? Then simpy use abs
Gurjeevan
on 4 Aug 2023
Gurjeevan
on 4 Aug 2023
Gurjeevan
on 4 Aug 2023
Dyuman Joshi
on 7 Aug 2023
Edited: Dyuman Joshi
on 7 Aug 2023
"How do i store ds_mapping as a vector?"
Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
