Updating with for-loop (straightforward)
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Fiona Rae
el 10 de Jul. de 2017
Comentada: Fiona Rae
el 10 de Jul. de 2017
AA =
2 8 4.........
4 9 34.........
BB =
4 5 2.........
9 23 11.........
dt = 0.1 % time step
for t = 0:dt:4
pA = AA(:, t+1)
pB = BB(:, t+1)
end
There are several other columns for AA and BB. At t = 0, I need to assign the first columns of AA and BB to pA and pB respectively. At t = 0.1, the second columns. At t = 0.2, the third columns and so on.
I know the error is in AA(:, t+1) and BB(:, t+1) because t is in decimals and column numbers cannot be in decimals. I just don't know how to rectify it.
0 comentarios
Respuesta aceptada
David Goodmanson
el 10 de Jul. de 2017
Editada: David Goodmanson
el 10 de Jul. de 2017
Hello Fiona,
One way is to use an index to address AA and BB and to calculate t. You have 41 possible values for t, so
for n = 1:41
pA = AA(:,n)
pB = BB(:,n)
t = .1*(n-1); % relationship between n and t
(possibly more calculations involving t inside the loop are here)
end
pA and pB change every time in the loop and are not being saved, so I assume you are doing some calculation with them inside the loop.
Más respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!