Hi I need help with for loop
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi I'm very new to matlab and was wondering if there was a way to code all of this within just one for loop
댓글 수: 0
채택된 답변
추가 답변 (1개)
Akira Agata
2020년 8월 12일
No need to use for-loop. How about the following way?
% Read data file
T1 = readtable('A1_input.txt');
% Postion of (x,y) at time = 0
x0 = 4;
y0 = 0;
% Calculate the position for each time step
xPos = cumtrapz(T1.time, T1.vx) + x0;
yPos = cumtrapz(T1.time, T1.vx) + y0;
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!