for in for loop
1 Ansicht (letzte 30 Tage)
Marko Niko am 7 Feb. 2023
I have the following code:
for i=1:time time = [1:1:999]
CE(i,k) = Ep(i) * Dp(j);
ETRF_p(i,k) = Mass_C2* Ep(i) * Dp(j);
- What does the (i,k) mean? does the loop go through all values of i and k?
- How will the output look it?
Tushar Behera am 7 Feb. 2023
I believe you want to understand the code in your question and how the loop will work.
The code you have written will only loop through once. I believe that is not your desired behaviour.
The (i,k) in CE(i,k) and ETRF_p(i,k) represents a matrix index. The loop is supposed to construct a matrix by assigning values to each element of the matrix CE and ETRF_p. With your current code the output will be a single valued scalar.
It will be of great help if you provide little more context as of what you want to acheive with your code.