Combining 2 Cell elements as a single element

I can't really describe the problem I am having. Here is the code so far,
rows={'r','r','r','r','r','r','r','r','r'};
cols={'c','c','c','c','c','c','c','c','c'};
r=genvarname(rows);
c=genvarname(cols);
I am looking to create a 9x9 grid, in which is of the format rc, r1c1,r2c2,r3c3...r9c9. Each variable will also have multiple values stored as matrices eg, r1c1=[1,2,3].
// I am writing on the R2015a software, but will be doing most of the work on R2016a at home.

1 件のコメント

Alexandra Harkai
Alexandra Harkai 2016 年 11 月 29 日
Since this kind of variable names are generally advised against, may I ask why do you need the variable names in this format?

サインインしてコメントする。

回答 (1 件)

Jan
Jan 2016 年 11 月 29 日
編集済み: Jan 2016 年 11 月 29 日

1 投票

Do not create variables dynamically. This is a really bad programming practize and you find dozens of discussions to this topic in the forum. E.g.: http://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval
The complicated methods to create variables dynamically demand for even more complicated methods to access them later on. The runtime degrades remarkably (factor of 100 is possible) and debugging gets horror. Use arrays and indexing instead of hiding the indices in the names of the variables.

カテゴリ

ヘルプ センター および File ExchangeMatrices and Arrays についてさらに検索

質問済み:

2016 年 11 月 28 日

編集済み:

Jan
2016 年 11 月 29 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by