Dynamic Structure Fieldnames using Genvarname() Invalid
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
The help for genvarname() specifically says "If you use genvarname to generate a field name for a structure, MATLAB does create a variable for the structure and field in the MATLAB workspace. See Example 3, below."
The following code results in the following error at the first instance of genvarname(): "??? Argument to dynamic structure reference must evaluate to a valid field name."
count = 0;
while(true)
count = count + 1;
datafolder{count} = uigetdir(cd,...
'Select the folder containing first test event:');
if(~datafolder{count})
datafolder(count) = [];
break;
end
testname{count} = inputdlg({'Name of this test event'},'Name Test Event');
if(isempty(testname{count}))
error('No name entered');
end
end
for test = 1:length(testname)
testevents.(genvarname(testname{test})) =...
processDataFolder(datafolder{test});
testevents.(genvarname(testname{test})) =...
analyzeData(testevents.(testname{test}));
plotData(...
testevents.(genvarname(testname{test})),...
testname{test});
plotAverages(...
testevents.(genvarname(testname{test})),...
testname{test});
end
Very confused. 'Test120112' was used as the input.
0 Commenti
Risposta accettata
per isakson
il 13 Gen 2012
The variable, testname, is a cell array of cells. Your code assumes it to be a cell array of strings
K>> class( testname{1} )
ans =
cell
Più risposte (1)
Vedere anche
Categorie
Scopri di più su Structures in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!