# How can i program the location function of x depending on the time?

조회 수: 3(최근 30일)
Arian Catic Nitsche 2019년 10월 15일
답변: Pranjal Kaura 2021년 8월 30일
I want to calculate the different position x(T), with the eq. below, at time T. Where x(0) is the position at tome t=0. and N is the number of sensor readings. ax(n) describes the acceleration at reading n.
Given is the T = Timematricx (N*1) and ax(n) = Accelerationmatrix (N*1). Also N, the number of sensorreadings is given. x(0) is also defined.
The goal is to have at the end a postion vector (N*1) Matricx! So how can i write a function/ script to reach the goal? ##### 댓글 수: 1표시숨기기 없음
KALYAN ACHARJYA 2019년 10월 15일
Have you tried?

댓글을 달려면 로그인하십시오.

### 답변(1개)

Pranjal Kaura 2021년 8월 30일
Hey,
It is my understanding that you want to develop a function to find x(T) using the given formula
You can refer to the function documentation to learn about creating functions in MATLAB.
Here is a code snippet:
function xT = calcPosition(x0, T, Ax, N)
xT = x0 + T.*T*(sum(Ax)/N);
end

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!