Use function inside a loop that gives the function's output multiple times - How to avoid overwriting output?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Dimitris K
el 3 de Ag. de 2021
Comentada: Stephen23
el 4 de Ag. de 2021
Hello everyone,
I am using a function that i have wrtitten inside a for loop..
i.e. for i=1:100
S=function_example(S,etc)
end
The output of one step is input for the function in the next step and so on...
I know that i can use indexing and an array S to store everything there (e.g S(i+1), S(i))... However I am looking for a more sophisticated way!!
Is there one ?? I need these looped function outputs for plotting my results...
0 comentarios
Respuesta aceptada
Yongjian Feng
el 3 de Ag. de 2021
If you want to plot it, you need the array, right? What else do you have in mind then?
5 comentarios
Stephen23
el 4 de Ag. de 2021
" I was trying to avoid using all the i+1 etc cause sometimes it can be confusing for someone that reads my code"
Indexing is a basic MATLAB technique for accessing data in arrays.
You can assume that in general someone reading MATLAB code will not be confused by a simple i+1 index.
Más respuestas (0)
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!