Filter löschen
Filter löschen

How can I get a variable from inside of the for loop and use it after it ends?

3 Ansichten (letzte 30 Tage)
if (M ~= M2)
C=padarray(x,[21,0],0,'post');
sz=size(C)
end
I would like to use 'sz' outside the loop for the rest of my code
  1 Kommentar
James Tursa
James Tursa am 20 Mär. 2018
What is preventing you from doing so? Is the code you show inside of your loop? It would help if you show that code also so we can better understand your problem.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Amjad Green
Amjad Green am 20 Mär. 2018
if you want the value of the variable at a certain point in the for loop,you can save it in a different variable at that iteration then after the for loop is finished save it back int its original variable name

Weitere Antworten (0)

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