Hi I need help with for loop
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Benedict Comerford
il 12 Ago 2020
Commentato: Benedict Comerford
il 12 Ago 2020
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 Commenti
Risposta accettata
Più risposte (1)
Akira Agata
il 12 Ago 2020
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;
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!