本文介绍了如何声明由其他变量组成的变量名(MATLAB)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个变量,该变量需要依赖于循环内的另一个变量:

I have a Variable that needs to be dependent on another variable inside a loop:

for n=1:100

newfilename="NEW_FILE_1.txt"

end

其中的"1"必须等于n:所以第一个循环为1,第二个循环为2,依此类推.

where the "1" needs to be what ever n is: So 1 for the first loop and 2 for the second loop and so on and so forth.

如何设置声明"newfilename"的名称中包含变量"n"的变量?

How do you set up declaring "newfilename" to have the variable "n" variable inside its name?

谢谢

推荐答案

for n=1:100
    newfilename = ['NEW_FILE_' num2str(n) '.txt'];
end

这篇关于如何声明由其他变量组成的变量名(MATLAB)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 18:50
查看更多