Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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)')

Respuestas (1)

Anmol Dhiman
Anmol Dhiman el 8 de Abr. de 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

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by