Filter löschen
Filter löschen

for loop reference solution (from coursera) question

5 Ansichten (letzte 30 Tage)
Sara Ismail-Sutton
Sara Ismail-Sutton am 14 Mär. 2021
Beantwortet: Shubham Rawat am 17 Mär. 2021
Sorry if this is a stupid question, but I am pretty new to matlab, looking at this solution at the loop "for n=1:nint@" I can't see how this works as there isn't a variable allocated "n", just "nx" and "ny". and the other functions in the loop are functions of 'Z' or 'z'.
Many thanks for your help.
  1 Kommentar
Russel Burgess
Russel Burgess am 14 Mär. 2021
The for loop expression creates the variable, i.e.,
for n=1:nit
Will create a variable, n, initially set to 1. n is persistent, i.e., it will still exist after the foor loop is done - with the value nit, assuming nothing caused the for loop to break out early.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Shubham Rawat
Shubham Rawat am 17 Mär. 2021
Hi Sara,
Comment is correct only inside for loop the variable n is instantiated.
You may look into this documentation for further help:
Hope this Helps!

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by