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

1 次查看(过去 30 天)
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 个评论
James Tursa
James Tursa 2018-3-20
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.

请先登录,再进行评论。

采纳的回答

Amjad Green
Amjad Green 2018-3-20
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

更多回答(0 个)

类别

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