Indexing array element with for loop with specified step size
古いコメントを表示
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 件のコメント
Cris LaPierre
2021 年 12 月 24 日
How is your data stored in each column? You example suggests that each of the 331 columns contain 4 atom coordinates. Is that correct?
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Image Quality についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!