Indexing array element with for loop with specified step size
Mostrar comentarios más antiguos
Hi MATLAB users,
I have a data file for 1 row and 332 columns. The first column correspond to time vale and rest 331 coliumns correspond to coordinate values of atoms of a molecule. I want to multiply each atom by certain value to get my output. But since my column numbers are odd, I am not able to specify the exact step size in the for loop.
Example,
My input file looks like the following
|<- Molecule 1 ->| |<- Molecule 2 ->| ................ <- Molecule 331->
Time_value ATOM1 ATOM2 ATOM3 ATOM4 ATOM1 ATOM 2ATOM3 ATOM4.....................
I have to multiply ATOM1 by 2, ATOM2 by 3, ATOM3 by 5 and ATOM4 by 8.
Following is my code:
for i = 2:4:331
X = 2*ATOM1 + 3*ATOM2 + 5*ATOM3 + 8*ATOM4;
end
I am not able to get the correct output as desired.
It will be very nice if anyone can help me.
Thanks in advance !
1 comentario
Cris LaPierre
el 24 de Dic. de 2021
How is your data stored in each column? You example suggests that each of the 331 columns contain 4 atom coordinates. Is that correct?
Respuestas (0)
Categorías
Más información sobre Image Quality en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!