Use parametric Name generator to adress existing cell arrays

1 次查看(过去 30 天)
Hello,
I generated 36 cell arrays as I need to evaluate a lot of files for my masters thesis. The files are named myself and conain infos about temperature, material etc.
So build a name-generator for me to store the values in the right cell array.
My question is, how can I use a name I created as a pathname?
SED_B_S235_M20 = cell(1,4), 'VariableNames', {'Filename','FORCE_Stress','ZERO_Stress','NumberOfCycles'};
% and so on.. so the parts are:
AssMeth='SED';
Geo='B';
Steel='S235';
Temp='M20';
%of course there are much more; just shortened for it to work
TableName= sprintf('%s_%s_%s_%s', AssMeth,Geo,Steel,Temp)
TableName = 'SED_B_S235_M20' is the right output and I have a Cell array called exactly the same. How do write e.g. 1234 into the first row and the first coloum of the cell array using "TableName".
Using TableName(1,1)=1234 obiously does not work and I don't know what command I need to look for.
Thank very much in advance!

采纳的回答

Jeff Miller
Jeff Miller 2019-3-1
One almost-convenient way to do this is to put all of your cell arrays within a structure, call it 'a'.
So, for example, create your first cell array within this structure like this:
a.SED_B_S235_M20 = cell(1,4), 'VariableNames', {'Filename','FORCE_Stress','ZERO_Stress','NumberOfCycles'};
% and so on..
Now you can refer to that component of the structure by putting the string in parentheses, something like this:
TableName= sprintf('%s_%s_%s_%s', AssMeth,Geo,Steel,Temp);
a.(TableName)(1,1) = 1234; % Should this be {1,1} with curly brackets since it is a cell?

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by