可能重複:
How to concatenate a number to a variable name in MATLAB?
MATLAB: How can I use a variables value in another variables name?Matlab-如何基於其他變量的值命名新變量?
我想名稱中使用的函數給出其他變量的值的變量。 因此,如果我的值爲x1,x2,我可以將新變量的名稱設爲:
x_(x1's value)_(x2的值)作爲名稱。
我已經簽出了eval,num2str,strcat函數,但是至今我還是無法做到這一點,所以我有一個變量名稱,上面我可以指定一個值。
任何幫助將不勝感激。
這聽起來像你應該使用數組來代替。 – JoshD 2010-10-07 18:40:41
這種事情已經被覆蓋了幾次:[Matlab的:在另一個變量名稱中使用變量的值?](http://stackoverflow.com/questions/3346178/matlab-using-a-variables-value-in -another-variables-name),[如何在MATLAB中將數字連接到變量名?](http://stackoverflow.com/questions/2809635/how-to-concatenate-a-number-to-a-variable -name-in-matlab),[使用MATLAB循環函數來命名計算變量](http://stackoverflow.com/questions/3143959/using-matlab-loop-funtion-to-name-calculate-variables)。 – gnovice 2010-10-07 18:44:59
閱讀@MatlabDoug的錯誤編碼實踐列表,特別是第一點http://blogs.mathworks.com/videos/2010/03/08/top-10-matlab-code-practices-that-make-me -cry/ – Amro 2010-10-07 18:53:05