MATLAB: How can I use a variables value in another variables name? -
I'm thinking this is possible. My code looks like this:
indexStop = find (firstinSeq (x, 4) ~ = ... littledataPassed (y: length (littledataPassed), 4), 1, 'first') ; For Z = 0: (n-1) index process = search ((Lititatappassed (y: y + indexStop-1,6) == 1 & amp; ... Litatatap (y: y + indexStop-1,2 ) == firstinSeq (X, 2) & amp; ... Litaladapted (y: y + indexSet-1.5) == z), 1, 'first'); If imprim (index process) msglength [n] (countangaleeng [n], :) = [first six (x, :) [0] 0]]; And msglength [n] (countmsgLength [n], :) = [firstinSeq (x, :) ... littledataPassed (y + indexing process-1, :)]; End count [n] = counting gal [n] + 1; End
I think that [n]
can be switched to the actual value of n
, expected to be everywhere As I use it to add data to nine different variables in format msgLength #
. I have tried to find a tutorial and not what I have not seen anything on the subject.
This is almost always, for example, you have a1
, A2
, a3
, it is better to use arrays or to store data to create a bunch of variables named. Start msgLength
as a cell array with n
elements:
msgLength = cell (1, n);
And you can access cells of msgLength
using curly braces:
msgLength {n} = .. Some values for the cell. Assign.% # Your variable countmsgLength
can be just a regular numerical array, because it is only n
The values are stored, you just need to change the brackets in square brackets (i.e. [n]
to (n)
).
However , if you want to actually make different variables by n
Will end using the function. And show some examples of how to prepare variable names using the value of any other variable.
Comments
Post a Comment