trouble plotting driving style from acceleration
Mostrar comentarios más antiguos
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 comentarios
Dyuman Joshi
el 4 de Ag. de 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
el 4 de Ag. de 2023
Gurjeevan
el 4 de Ag. de 2023
Gurjeevan
el 4 de Ag. de 2023
Dyuman Joshi
el 7 de Ag. de 2023
Editada: Dyuman Joshi
el 7 de Ag. de 2023
"How do i store ds_mapping as a vector?"
Respuestas (0)
Categorías
Más información sobre MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

