trouble plotting driving style from acceleration
이전 댓글 표시
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
Dyuman Joshi
2023년 8월 4일
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
2023년 8월 4일
Gurjeevan
2023년 8월 4일
Gurjeevan
2023년 8월 4일
Dyuman Joshi
2023년 8월 7일
편집: Dyuman Joshi
2023년 8월 7일
"How do i store ds_mapping as a vector?"
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

