Indexing a cell array column from multiple sources

1 次查看(过去 30 天)
Hi, I need to index a column of a 'results' table using different different sources.
The first row is empty (' '), the rows after that are the names from a filelist ('FileList.name'), this works fine.
However, the rows after that I'd like to assign elements from my string 'combinedToneNames'.
But I can't get this to work nicely: getting all 3 tone names (see snippet below) to show up below each other in new rows.
combinedToneNames = ['ClowD(-0dB)', 'EF(-0dB)', 'BChigh(-0dB)'];
results = {'', FileList.name, combinedToneNames}';
This gives the following result, I've clarified it a bit as well as added what I'd want it to be like:
combinedToneNames appears to be a 1x31 char, so I then tried splitting the string on whitespaces ( )
combinedToneNames = ['ClowD(-0dB)' 'EF(-0dB)' 'BChigh(-0dB)'];
splitCombToneNames = split(combinedToneNames);
results = {'', FileList.name, splitCombToneNames}';
This gave the exact same result as above.
I also tried looping through combinedToneNames:
combinedToneNames = ['ClowD(-0dB)', 'EF(-0dB)', 'BChigh(-0dB)'];
for kk = 1:length(combinedToneNames)
results = {'', FileList.name, combinedToneNames(kk)}';
end
This gave:
Anyone knows how to get information from a char to index different rows?

采纳的回答

madhan ravi
madhan ravi 2020-7-11
FileList.name = {'sjdjd.wav', 'sjdjf.wav'}; % example names
combinedToneNames = {'ClowD(-0dB)', 'EF(-0dB)', 'BChigh(-0dB)'};
results = [{[]}, FileList.name, combinedToneNames].'

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by