Effacer les filtres
Effacer les filtres

How to calculate acceleration between two cells from data using for...end

1 vue (au cours des 30 derniers jours)
Favour Akhetuamen
Favour Akhetuamen le 3 Avr 2020
I'm really new to MatLab and my programming moduel uses it. My task is to calculate accleration between two cells using the for loop command. this is my code so far but it doesnt work. Please help.
x=ev_data.Time; %time in seconds [Time]
y=ev_data.Speed;
ii=1;
for i=ev_data.Time
y1(ii)=(((ev_data.Speed+1)-ev_data.Speed)/ev_data.Time);
ii=ii+1;
end
figure;
plot(x,y1);
hold on;
plot(x,y)
legend('derivate approximated','sin(x)')

Réponses (1)

Anmol Dhiman
Anmol Dhiman le 8 Avr 2020
Hi Favour,
I am assuming x and y are vectors(arrays). For each time interval you are calculating acceleration(y11). YOu can follow the below code
x=ev_data.Time; %time in seconds [Time]
y=ev_data.Speed;
for i=1:ev_data.Time
y1(i)=(((y(i)+1)-y(i))/x(i));
end
figure;
plot(x,y1);
hold on;
plot(x,y);
legend('derivate approximated','sin(x)') ;
Hope it helps
Thanks,
Anmol Dhiman

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by