필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
Favour Akhetuamen
Favour Akhetuamen 2020년 4월 3일
답변: Anmol Dhiman 2020년 4월 8일
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)')

답변 (1개)

Anmol Dhiman
Anmol Dhiman 2020년 4월 8일
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

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by