Hi,
I am trying to plot a graph of a vehicles type of acceleration ie. Eco, Nor, Agg, Any; from a set of data. I have tried everything that i have been tought but cant figure out what how to complete it. The graph needs to show all values in range 0.7 – 2.8 as 1, 2.81 – 3.64 as 2, 3.65 – 6.5 as 3 and every other value 0. I also needs to use variable ds_mapping to store corresponding classification values of 1,2 or 3.
my_data=readtable('Log_U0006387_160311_740d0.csv');speed2=my_data.Speed*0.44704; %Speed is extracted in m/s from the dataset
acceleration= diff(speed2)./diff(time); %Finds acceleration as a derivative of speed with respect to time
Acceleration= resample(acceleration, 621,620); %as acceleration had only 620 cells and time has 621 cells
ds_mapping=0;for Acceleration2=sqrt(Acceleration.^2); if Acceleration2>=0.7 & Acceleration2<=2.8; ds_mapping = ds_mapping+1; elseif Acceleration2>=2.81 & Acceleration2<=3.64; ds_mapping = ds_mapping+2; elseif Acceleration2>=3.65 & Acceleration2<=6.5; ds_mapping = ds_mapping+3; elseif Acceleration2<=2.80 & Acceleration2>=6.6; ds_mapping = ds_mapping+0; endend%Plot graph
figure (3)xlabel('Time (s)'); ylabel('Acceleration (m/s2)');plot(time, Acceleration, 'm', time, ds_mapping)
Best Answer