Changing part of a name of a variable in a for loop

  • Thread starter loukoumas
  • Start date
  • #1
15
0
changing part of a name of a variable in a "for" loop

hello everyone!

let's say i have the equation between two variables: DT10sec= A*T10sec, working in matlab. How can i use a "for" loop to calculate the equation DT20sec= A*T20sec DT30sec= A*T30sec, DT40sec= A*T40sec,... etc

How can i interfere in just a part of the name of a variable? i would suppose something like the following

for i=1:5
DT"i"sec= A* T"i"sec
end

but it is not the right symbol
 

Answers and Replies

  • #2
34,948
11,128


I would use an array. I don't know the matlab syntax, but most programming languages would write this as DTsec[10] or (with a variable i) DTsec[10*i].
 
  • #3
15
0


I would use an array. I don't know the matlab syntax, but most programming languages would write this as DTsec[10] or (with a variable i) DTsec[10*i].
DT..sec and T..sec are matrices and i m not interested on making an array of matrices. DT is the result from calculations (as T is a known matrix) for different time points and i just want to name my results according to the time point they refer to. But i am looking for a quicker way to do it, using a for loop. Thanks anyway
 

Related Threads on Changing part of a name of a variable in a for loop

Replies
4
Views
8K
Replies
16
Views
192K
Replies
2
Views
1K
Replies
3
Views
5K
Replies
5
Views
127K
Replies
1
Views
2K
Replies
3
Views
8K
Replies
2
Views
579
Top