Inserting a variable in a name of an object
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Royvg94
el 1 de Oct. de 2015
Respondida: Guillaume
el 1 de Oct. de 2015
Im using this code
C = 16
Sample = S1
S1 = Array1; %Sample1
S2 = Array2; %Sample2
S3 = Array3; %Sample3
S4 = Array4; %Sample4
column16_1 = cellfun(@(m) m(:, C), Sample, 'UniformOutput', false);
Can i change the name of the created array "column16_1" in this way:
columnC_Sample
So what I want is that, if I change the value of "C" and "Sample", I want matlab to automatically create a new name for the new created array.
I hope I made my problem clear enough.
Thanks for the help!
0 comentarios
Respuesta aceptada
Guillaume
el 1 de Oct. de 2015
It's possible, but DON'T. You'll be going down a path that is very inefficient, hard to debug, hard to edit, and simply prone to errors.
The proper way is to use a cell array indexed by column number and sample number. (or if all the columns are the same size, simply use plain multidimensional array). Similarly your sample arrays should be stored in a cell array, not in numbered variables:
Sample{1} = Array1; Sample{2} = Array2; Sample{3} = Array3; Sample{4} = Array4;
column{C, S} = cellfun(@(m) m(:, C), Sample{S}, 'UniformOutput', false);
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Multidimensional Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!