Create cell array with the same string n-times
    205 ビュー (過去 30 日間)
  
       古いコメントを表示
    
Hi all,
I have another problem I haven't found any soulution for yet.
I have a list of Values and I have the name of the .mat-file the values are saved in as a string.
For example
name='Values.mat'
values =
     1
     2
     3
     4
     5
Now I need to create a cell array with the name of the file for each value.
For example
>> values.filename
ans =
Values.mat Values.mat Values.mat Values.mat Values.mat
Does anybody know how I can create that cell array, size depending on how many values I have?
Thanks a lot! Oli
0 件のコメント
採用された回答
  Daniel Shub
      
      
 2011 年 10 月 2 日
        The names of your variables are a little confusing ... You are starting with values being a double array and then wanting values to be a structure ...
To answer your question you can create a cell array with the same string n-times with deal.
doc deal
Specifically you can make a 1x5 cell array filename have the value saved in name with:
[filename{1:5}] = deal(name);
you may want to consider a structure array ...
values = struct('value', mat2cell(values, 1, ones(5, 1)), 'filename', name)
2 件のコメント
その他の回答 (3 件)
参考
カテゴリ
				Help Center および File Exchange で Matrix Indexing についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!














