Is it possible to put a for loop outside of a function?

조회 수: 7 (최근 30일)
Noah Kilps
Noah Kilps 2020년 11월 13일
답변: KALYAN ACHARJYA 2020년 11월 13일
Hello,
I am writing a script, but I'm realizing a large chunk of it I want to be a function. I understand that you have to make the script end with the function if put a function in there. What I want to do is put the function in, and then loop that function however many times I need to. Since I know you have to put a function at the end, I was thinking I would then put a function outside that for loop so overall it would have a structure like this:
% script code
function
for
function
end
end
end
So,
  1. Is it possible to put a for loop outside a function?
  2. Would I then have to put a function outside the for loop so that it works in the script?
Thanks

답변 (1개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2020년 11월 13일
for loop
function call % Define the function as different script
end
#Hope I understand your question

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by