calling a matrix with different names in a for loop
4 次查看(过去 30 天)
显示 更早的评论
I have three matrixes with different names as NPV_1, NPV2 and NPV_3. I have tried the below but It did not work. Can you please help
for i = 1:3
fm =forfor sprintf('NPV_%d',i);
NPV_Mat = fm;
end
2 个评论
Stephen23
2019-9-5
"I have three matrixes with different names as NPV_1, NPV2 and NPV_3"
Accessing separate variable names like that is one way that beginners force themselves into writing slow, complex, obfuscated, buggy code that is hard to debug. Read this to know why:
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!