Inserting a variable in a name of an object
3 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Guillaume
2015 年 10 月 1 日
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Multidimensional Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!