# Store only 4 value from a loop

1 Ansicht (letzte 30 Tage)
m m am 13 Nov. 2019
Beantwortet: Adam am 13 Nov. 2019
Hello,
i have two loops as :
nt = 15;
n=2;
for t = 1 : nt
for i = 1 : n
x(i) = ....
end
end
what i want is to store tha table for t = 1 , t= 5, t= 10 and t= 15. because i get only the last value x(1) ,x(2) at t= 15 only)
please how can i do it?
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Antworten (1)

If you have a nested loop like that you would generally want something like
x(t,i) = ...
with a 2d output to match the 2 nested for loops. If you only want results stored at t = 1, 5, 10 and 15 though then sure the outer loop should reflect that:
for t = [1 5 10 15]
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by