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 Kommentar

Since this kind of variable names are generally advised against, may I ask why do you need the variable names in this format?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jan
Jan am 29 Nov. 2016
Bearbeitet: Jan am 29 Nov. 2016

1 Stimme

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.

Kategorien

Mehr zu Matrices and Arrays finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 28 Nov. 2016

Bearbeitet:

Jan
am 29 Nov. 2016

Community Treasure Hunt

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

Start Hunting!

Translated by