Hi I need help with for loop
1 次查看(过去 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!