Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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)')

Risposte (1)

Anmol Dhiman
Anmol Dhiman il 8 Apr 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

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by