필터 지우기
필터 지우기

Use function inside a loop that gives the function's output multiple times - How to avoid overwriting output?

조회 수: 2 (최근 30일)
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...

채택된 답변

Yongjian Feng
Yongjian Feng 2021년 8월 3일
If you want to plot it, you need the array, right? What else do you have in mind then?
  댓글 수: 5
Dimitris K
Dimitris K 2021년 8월 3일
Thanks a lot for your response. I will probably use an array eventually. I was trying to avoid using all the i+1 etc cause sometimes it can be confusing for someone that reads my code to understand but i will probably stick to it as it is the only way to go.
Stephen23
Stephen23 2021년 8월 4일
" 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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by