unpack cell array of letters to be plugged into individual-cell rows, in a vector

Dear Matlab,
I have a cell array of letters in each cell (they are channel labels), attached herein.
Eventually, I want to 'unpack' the string contents of each cell, and list them, in their own separate cell, splayed out as a row vector at the end of this below for-loop
(because in the end my GOAL is the have a list of channel locations on each experiment subject, with each subject on its own row)
(can even ignore the 1st 4 columns in the 'infon2' variable, and just make C as its own row, if easier). Hopefully this makes sense. Pls lmk if not.
as always, thanks much in advance for your help!!
Joanne
for k = 1:length(setl) % 'setl' is a list of file names for each subject
setlist = setl(k); %MAYBE CANT INDEX INTO A STRUCT
srate = num2str(200);
length1 = 2000;
ref = 3;
% initialize matrices on 1st subject
if k == 1
infon2 = strings([ length({setl.name}) 5 ]);
end % end initialization loop
infon2(k,:,:,:,:) = {num2str(k); srate; length1; ref; [c{:}]}';
close all;
end

4 Comments

Hopefully this makes sense. Pls lmk if not.
No, not to me. An example would be advisable.
Thanks for the feedback, ok let me explain more:
Your attached data doesn't contain anything like that.Each cell just contains a single char vector, not a vector of strings. Just attach the 240x5 infon2 variable that you've shown above.

Sign in to comment.

 Accepted Answer

load infon2
c=infon2(:,end);
L=max(cellfun(@numel,c));
for i=1:numel(c)
c{i}(end+1:L)="";
end
c=num2cell(vertcat(c{:}));
infon2=[infon2(:,1:end-1) , c]
infon2 = 240×47 cell array
Columns 1 through 13 {'1' } {'200' } {'150.995'} {'common'} {["Fp1-Ref"]} {["Fp2-Ref"]} {["F3-Ref"]} {["F4-Ref"]} {["C3-Ref"]} {["C4-Ref"]} {["P3-Ref"]} {["P4-Ref"]} {["O1-Ref"]} {'2' } {'200' } {'96.995' } {'common'} {["Fp1-Ref"]} {["Fp2-Ref"]} {["F3-Ref"]} {["F4-Ref"]} {["C3-Ref"]} {["C4-Ref"]} {["P3-Ref"]} {["P4-Ref"]} {["O1-Ref"]} {'3' } {'200' } {'219.995'} {'common'} {["Fp1-Ref"]} {["Fp2-Ref"]} {["F3-Ref"]} {["F4-Ref"]} {["C3-Ref"]} {["C4-Ref"]} {["P3-Ref"]} {["P4-Ref"]} {["O1-Ref"]} {'4' } {'200' } {'68.995' } {'common'} {["Fp1-Ref"]} {["Fp2-Ref"]} {["F3-Ref"]} {["F4-Ref"]} {["C3-Ref"]} {["C4-Ref"]} {["P3-Ref"]} {["P4-Ref"]} {["O1-Ref"]} {'5' } {'200' } {'289.995'} {'common'} {["Fp1-Ref"]} {["Fp2-Ref"]} {["F3-Ref"]} {["F4-Ref"]} {["C3-Ref"]} {["C4-Ref"]} {["P3-Ref"]} {["P4-Ref"]} {["O1-Ref"]} {'6' } {'200' } {'824.995'} {'common'} {["Fp1-Ref"]} {["Fp2-Ref"]} {["F3-Ref"]} {["F4-Ref"]} {["C3-Ref"]} {["C4-Ref"]} {["P3-Ref"]} {["P4-Ref"]} {["O1-Ref"]} {'7' } {'200' } {'218.995'} {'common'} {["Fp1-Ref"]} {["Fp2-Ref"]} {["F3-Ref"]} {["F4-Ref"]} {["C3-Ref"]} {["C4-Ref"]} {["P3-Ref"]} {["P4-Ref"]} {["O1-Ref"]} {'8' } {'200' } {'217.995'} {'common'} {["Fp1-Ref"]} {["Fp2-Ref"]} {["F3-Ref"]} {["F4-Ref"]} {["C3-Ref"]} {["C4-Ref"]} {["P3-Ref"]} {["P4-Ref"]} {["O1-Ref"]} {'9' } {'200' } {'58.995' } {'common'} {["Fp1-Ref"]} {["Fp2-Ref"]} {["F3-Ref"]} {["F4-Ref"]} {["C3-Ref"]} {["C4-Ref"]} {["P3-Ref"]} {["P4-Ref"]} {["O1-Ref"]} {'10'} {'200' } {'57.995' } {'common'} {["Fp1-Ref"]} {["Fp2-Ref"]} {["F3-Ref"]} {["F4-Ref"]} {["C3-Ref"]} {["C4-Ref"]} {["P3-Ref"]} {["P4-Ref"]} {["O1-Ref"]} {'11'} {'200' } {'43.995' } {'common'} {["Fp1-Ref"]} {["Fp2-Ref"]} {["F3-Ref"]} {["F4-Ref"]} {["C3-Ref"]} {["C4-Ref"]} {["P3-Ref"]} {["P4-Ref"]} {["O1-Ref"]} {'12'} {'1000'} {'41.579' } {'common'} {["Fp1-Ref"]} {["Fp2-Ref"]} {["F3-Ref"]} {["F4-Ref"]} {["C3-Ref"]} {["C4-Ref"]} {["P3-Ref"]} {["P4-Ref"]} {["O1-Ref"]} {'13'} {'200' } {'248.995'} {'common'} {["Fp1-Ref"]} {["Fp2-Ref"]} {["F3-Ref"]} {["F4-Ref"]} {["C3-Ref"]} {["C4-Ref"]} {["P3-Ref"]} {["P4-Ref"]} {["O1-Ref"]} {'14'} {'200' } {'319.995'} {'common'} {["Fp1-Ref"]} {["Fp2-Ref"]} {["F3-Ref"]} {["F4-Ref"]} {["C3-Ref"]} {["C4-Ref"]} {["P3-Ref"]} {["P4-Ref"]} {["O1-Ref"]} {'15'} {'200' } {'109.995'} {'common'} {["Fp1-Ref"]} {["Fp2-Ref"]} {["F3-Ref"]} {["F4-Ref"]} {["C3-Ref"]} {["C4-Ref"]} {["P3-Ref"]} {["P4-Ref"]} {["O1-Ref"]} {'16'} {'200' } {'89.995' } {'common'} {["Fp1-Ref"]} {["Fp2-Ref"]} {["F3-Ref"]} {["F4-Ref"]} {["C3-Ref"]} {["C4-Ref"]} {["P3-Ref"]} {["P4-Ref"]} {["O1-Ref"]} Columns 14 through 25 {["O2-Ref"]} {["F7-Ref"]} {["F8-Ref"]} {["T3-Ref"]} {["T4-Ref"]} {["T5-Ref"]} {["T6-Ref"]} {["Fz-Ref"]} {["Cz-Ref"]} {["Pz-Ref"]} {["POL E"]} {["POL PG1"]} {["O2-Ref"]} {["F7-Ref"]} {["F8-Ref"]} {["T3-Ref"]} {["T4-Ref"]} {["T5-Ref"]} {["T6-Ref"]} {["Fz-Ref"]} {["Cz-Ref"]} {["Pz-Ref"]} {["POL E"]} {["POL PG1"]} {["O2-Ref"]} {["F7-Ref"]} {["F8-Ref"]} {["T3-Ref"]} {["T4-Ref"]} {["T5-Ref"]} {["T6-Ref"]} {["Fz-Ref"]} {["Cz-Ref"]} {["Pz-Ref"]} {["POL E"]} {["POL PG1"]} {["O2-Ref"]} {["F7-Ref"]} {["F8-Ref"]} {["T3-Ref"]} {["T4-Ref"]} {["T5-Ref"]} {["T6-Ref"]} {["Fz-Ref"]} {["Cz-Ref"]} {["Pz-Ref"]} {["POL E"]} {["POL PG1"]} {["O2-Ref"]} {["F7-Ref"]} {["F8-Ref"]} {["T3-Ref"]} {["T4-Ref"]} {["T5-Ref"]} {["T6-Ref"]} {["Fz-Ref"]} {["Cz-Ref"]} {["Pz-Ref"]} {["POL E"]} {["POL PG1"]} {["O2-Ref"]} {["F7-Ref"]} {["F8-Ref"]} {["T3-Ref"]} {["T4-Ref"]} {["T5-Ref"]} {["T6-Ref"]} {["Fz-Ref"]} {["Cz-Ref"]} {["Pz-Ref"]} {["POL E"]} {["POL PG1"]} {["O2-Ref"]} {["F7-Ref"]} {["F8-Ref"]} {["T3-Ref"]} {["T4-Ref"]} {["T5-Ref"]} {["T6-Ref"]} {["Fz-Ref"]} {["Cz-Ref"]} {["Pz-Ref"]} {["POL E"]} {["POL PG1"]} {["O2-Ref"]} {["F7-Ref"]} {["F8-Ref"]} {["T3-Ref"]} {["T4-Ref"]} {["T5-Ref"]} {["T6-Ref"]} {["Fz-Ref"]} {["Cz-Ref"]} {["Pz-Ref"]} {["POL E"]} {["POL PG1"]} {["O2-Ref"]} {["F7-Ref"]} {["F8-Ref"]} {["T3-Ref"]} {["T4-Ref"]} {["T5-Ref"]} {["T6-Ref"]} {["Fz-Ref"]} {["Cz-Ref"]} {["Pz-Ref"]} {["POL E"]} {["POL PG1"]} {["O2-Ref"]} {["F7-Ref"]} {["F8-Ref"]} {["T3-Ref"]} {["T4-Ref"]} {["T5-Ref"]} {["T6-Ref"]} {["Fz-Ref"]} {["Cz-Ref"]} {["Pz-Ref"]} {["POL E"]} {["POL PG1"]} {["O2-Ref"]} {["F7-Ref"]} {["F8-Ref"]} {["T3-Ref"]} {["T4-Ref"]} {["T5-Ref"]} {["T6-Ref"]} {["Fz-Ref"]} {["Cz-Ref"]} {["Pz-Ref"]} {["POL E"]} {["POL PG1"]} {["O2-Ref"]} {["F7-Ref"]} {["F8-Ref"]} {["T3-Ref"]} {["T4-Ref"]} {["T5-Ref"]} {["T6-Ref"]} {["Fz-Ref"]} {["Cz-Ref"]} {["Pz-Ref"]} {["POL E"]} {["POL PG1"]} {["O2-Ref"]} {["F7-Ref"]} {["F8-Ref"]} {["T3-Ref"]} {["T4-Ref"]} {["T5-Ref"]} {["T6-Ref"]} {["Fz-Ref"]} {["Cz-Ref"]} {["Pz-Ref"]} {["POL E"]} {["POL PG1"]} {["O2-Ref"]} {["F7-Ref"]} {["F8-Ref"]} {["T3-Ref"]} {["T4-Ref"]} {["T5-Ref"]} {["T6-Ref"]} {["Fz-Ref"]} {["Cz-Ref"]} {["Pz-Ref"]} {["POL E"]} {["POL PG1"]} {["O2-Ref"]} {["F7-Ref"]} {["F8-Ref"]} {["T3-Ref"]} {["T4-Ref"]} {["T5-Ref"]} {["T6-Ref"]} {["Fz-Ref"]} {["Cz-Ref"]} {["Pz-Ref"]} {["POL E"]} {["POL PG1"]} {["O2-Ref"]} {["F7-Ref"]} {["F8-Ref"]} {["T3-Ref"]} {["T4-Ref"]} {["T5-Ref"]} {["T6-Ref"]} {["Fz-Ref"]} {["Cz-Ref"]} {["Pz-Ref"]} {["POL E"]} {["POL PG1"]} Columns 26 through 36 {["POL PG2"]} {["A1-Ref"]} {["A2-Ref"]} {["POL T1"]} {["POL T2"]} {["POL X1"]} {["POL X2"]} {["POL DC01"]} {["POL DC02"]} {["POL DC03"]} {["POL $A1" ]} {["POL PG2"]} {["A1-Ref"]} {["A2-Ref"]} {["POL T1"]} {["POL T2"]} {["POL X1"]} {["POL X2"]} {["POL DC01"]} {["POL DC02"]} {["POL DC03"]} {["POL $A1" ]} {["POL PG2"]} {["A1-Ref"]} {["A2-Ref"]} {["POL T1"]} {["POL T2"]} {["POL X1"]} {["POL X2"]} {["POL X3" ]} {["POL X4" ]} {["POL DC01"]} {["POL DC02"]} {["POL PG2"]} {["A1-Ref"]} {["A2-Ref"]} {["POL T1"]} {["POL T2"]} {["POL X1"]} {["POL X2"]} {["POL X3" ]} {["POL X4" ]} {["POL DC01"]} {["POL DC02"]} {["POL PG2"]} {["A1-Ref"]} {["A2-Ref"]} {["POL T1"]} {["POL T2"]} {["POL X1"]} {["POL X2"]} {["POL DC01"]} {["POL DC02"]} {["POL DC03"]} {["POL $A1" ]} {["POL PG2"]} {["A1-Ref"]} {["A2-Ref"]} {["POL T1"]} {["POL T2"]} {["POL X1"]} {["POL X2"]} {["POL DC01"]} {["POL DC02"]} {["POL DC03"]} {["POL $A1" ]} {["POL PG2"]} {["A1-Ref"]} {["A2-Ref"]} {["POL T1"]} {["POL T2"]} {["POL X1"]} {["POL X2"]} {["POL DC01"]} {["POL DC02"]} {["POL DC03"]} {["POL $A1" ]} {["POL PG2"]} {["A1-Ref"]} {["A2-Ref"]} {["POL T1"]} {["POL T2"]} {["POL X1"]} {["POL X2"]} {["POL X3" ]} {["POL X4" ]} {["POL DC01"]} {["POL DC02"]} {["POL PG2"]} {["A1-Ref"]} {["A2-Ref"]} {["POL T1"]} {["POL T2"]} {["POL X1"]} {["POL X2"]} {["POL X3" ]} {["POL X4" ]} {["POL DC01"]} {["POL DC02"]} {["POL PG2"]} {["A1-Ref"]} {["A2-Ref"]} {["POL T1"]} {["POL T2"]} {["POL X1"]} {["POL X2"]} {["POL X3" ]} {["POL X4" ]} {["POL DC01"]} {["POL DC02"]} {["POL PG2"]} {["A1-Ref"]} {["A2-Ref"]} {["POL T1"]} {["POL T2"]} {["POL X1"]} {["POL X2"]} {["POL X3" ]} {["POL X4" ]} {["POL DC01"]} {["POL DC02"]} {["POL PG2"]} {["A1-Ref"]} {["A2-Ref"]} {["POL T1"]} {["POL T2"]} {["POL X1"]} {["POL X2"]} {["POL $A1" ]} {["POL $A2" ]} {["" ]} {["" ]} {["POL PG2"]} {["A1-Ref"]} {["A2-Ref"]} {["POL T1"]} {["POL T2"]} {["POL X1"]} {["POL X2"]} {["POL $A1" ]} {["POL $A2" ]} {["" ]} {["" ]} {["POL PG2"]} {["A1-Ref"]} {["A2-Ref"]} {["POL T1"]} {["POL T2"]} {["POL X1"]} {["POL X2"]} {["POL $A1" ]} {["POL $A2" ]} {["" ]} {["" ]} {["POL PG2"]} {["A1-Ref"]} {["A2-Ref"]} {["POL T1"]} {["POL T2"]} {["POL X1"]} {["POL X2"]} {["POL $A1" ]} {["POL $A2" ]} {["" ]} {["" ]} {["POL PG2"]} {["A1-Ref"]} {["A2-Ref"]} {["POL T1"]} {["POL T2"]} {["POL X1"]} {["POL X2"]} {["POL $A1" ]} {["POL $A2" ]} {["" ]} {["" ]} Columns 37 through 47 {["POL $A2" ]} {["" ]} {["" ]} {["" ]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {["POL $A2" ]} {["" ]} {["" ]} {["" ]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {["POL DC03"]} {["POL DC04"]} {["POL $A1"]} {["POL $A2"]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {["POL DC03"]} {["POL DC04"]} {["POL $A1"]} {["POL $A2"]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {["POL $A2" ]} {["" ]} {["" ]} {["" ]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {["POL $A2" ]} {["" ]} {["" ]} {["" ]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {["POL $A2" ]} {["" ]} {["" ]} {["" ]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {["POL DC03"]} {["POL DC04"]} {["POL $A1"]} {["POL $A2"]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {["POL DC03"]} {["POL DC04"]} {["POL $A1"]} {["POL $A2"]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {["POL DC03"]} {["POL DC04"]} {["POL $A1"]} {["POL $A2"]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {["POL DC03"]} {["POL DC04"]} {["POL $A1"]} {["POL $A2"]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {["" ]} {["" ]} {["" ]} {["" ]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {["" ]} {["" ]} {["" ]} {["" ]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {["" ]} {["" ]} {["" ]} {["" ]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {["" ]} {["" ]} {["" ]} {["" ]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {["" ]} {["" ]} {["" ]} {["" ]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]} {[""]}

2 Comments

But why have a cell array at all? Why not just make infon2 into a big string matrix,
load infon2
c=infon2(:,end);
L=max(cellfun(@numel,c));
for i=1:numel(c)
c{i}(end+1:L)="";
end
c=vertcat(c{:});
infon2=[string(infon2(:,1:end-1)) , c];
Matt I'm so happy both work great! Thank you!!

Sign in to comment.

More Answers (1)

Why are you storing numeric data as text? That must make data processing very awkward: most likely better data design would be to use e.g. a table, which lets you keep all of the data types of each column i.e. store and process numeric data as numeric.
S = load('infon2.mat');
C = S.infon2
C = 240×5 cell array
{'1' } {'200' } {'150.995'} {'common'} {["Fp1-Ref" "Fp2-Ref" … ]} {'2' } {'200' } {'96.995' } {'common'} {["Fp1-Ref" "Fp2-Ref" … ]} {'3' } {'200' } {'219.995'} {'common'} {["Fp1-Ref" "Fp2-Ref" … ]} {'4' } {'200' } {'68.995' } {'common'} {["Fp1-Ref" "Fp2-Ref" … ]} {'5' } {'200' } {'289.995'} {'common'} {["Fp1-Ref" "Fp2-Ref" … ]} {'6' } {'200' } {'824.995'} {'common'} {["Fp1-Ref" "Fp2-Ref" … ]} {'7' } {'200' } {'218.995'} {'common'} {["Fp1-Ref" "Fp2-Ref" … ]} {'8' } {'200' } {'217.995'} {'common'} {["Fp1-Ref" "Fp2-Ref" … ]} {'9' } {'200' } {'58.995' } {'common'} {["Fp1-Ref" "Fp2-Ref" … ]} {'10'} {'200' } {'57.995' } {'common'} {["Fp1-Ref" "Fp2-Ref" … ]} {'11'} {'200' } {'43.995' } {'common'} {["Fp1-Ref" "Fp2-Ref" … ]} {'12'} {'1000'} {'41.579' } {'common'} {["Fp1-Ref" "Fp2-Ref" … ]} {'13'} {'200' } {'248.995'} {'common'} {["Fp1-Ref" "Fp2-Ref" … ]} {'14'} {'200' } {'319.995'} {'common'} {["Fp1-Ref" "Fp2-Ref" … ]} {'15'} {'200' } {'109.995'} {'common'} {["Fp1-Ref" "Fp2-Ref" … ]} {'16'} {'200' } {'89.995' } {'common'} {["Fp1-Ref" "Fp2-Ref" … ]}
N = size(C,1);
D = cell(N,0);
for k = 1:N
V = cellstr(C{k,5});
D(k,1:numel(V)) = V;
end
D = [C(:,1:4),D]
D = 240×47 cell array
Columns 1 through 14 {'1' } {'200' } {'150.995'} {'common'} {'Fp1-Ref'} {'Fp2-Ref'} {'F3-Ref'} {'F4-Ref'} {'C3-Ref'} {'C4-Ref'} {'P3-Ref'} {'P4-Ref'} {'O1-Ref'} {'O2-Ref'} {'2' } {'200' } {'96.995' } {'common'} {'Fp1-Ref'} {'Fp2-Ref'} {'F3-Ref'} {'F4-Ref'} {'C3-Ref'} {'C4-Ref'} {'P3-Ref'} {'P4-Ref'} {'O1-Ref'} {'O2-Ref'} {'3' } {'200' } {'219.995'} {'common'} {'Fp1-Ref'} {'Fp2-Ref'} {'F3-Ref'} {'F4-Ref'} {'C3-Ref'} {'C4-Ref'} {'P3-Ref'} {'P4-Ref'} {'O1-Ref'} {'O2-Ref'} {'4' } {'200' } {'68.995' } {'common'} {'Fp1-Ref'} {'Fp2-Ref'} {'F3-Ref'} {'F4-Ref'} {'C3-Ref'} {'C4-Ref'} {'P3-Ref'} {'P4-Ref'} {'O1-Ref'} {'O2-Ref'} {'5' } {'200' } {'289.995'} {'common'} {'Fp1-Ref'} {'Fp2-Ref'} {'F3-Ref'} {'F4-Ref'} {'C3-Ref'} {'C4-Ref'} {'P3-Ref'} {'P4-Ref'} {'O1-Ref'} {'O2-Ref'} {'6' } {'200' } {'824.995'} {'common'} {'Fp1-Ref'} {'Fp2-Ref'} {'F3-Ref'} {'F4-Ref'} {'C3-Ref'} {'C4-Ref'} {'P3-Ref'} {'P4-Ref'} {'O1-Ref'} {'O2-Ref'} {'7' } {'200' } {'218.995'} {'common'} {'Fp1-Ref'} {'Fp2-Ref'} {'F3-Ref'} {'F4-Ref'} {'C3-Ref'} {'C4-Ref'} {'P3-Ref'} {'P4-Ref'} {'O1-Ref'} {'O2-Ref'} {'8' } {'200' } {'217.995'} {'common'} {'Fp1-Ref'} {'Fp2-Ref'} {'F3-Ref'} {'F4-Ref'} {'C3-Ref'} {'C4-Ref'} {'P3-Ref'} {'P4-Ref'} {'O1-Ref'} {'O2-Ref'} {'9' } {'200' } {'58.995' } {'common'} {'Fp1-Ref'} {'Fp2-Ref'} {'F3-Ref'} {'F4-Ref'} {'C3-Ref'} {'C4-Ref'} {'P3-Ref'} {'P4-Ref'} {'O1-Ref'} {'O2-Ref'} {'10'} {'200' } {'57.995' } {'common'} {'Fp1-Ref'} {'Fp2-Ref'} {'F3-Ref'} {'F4-Ref'} {'C3-Ref'} {'C4-Ref'} {'P3-Ref'} {'P4-Ref'} {'O1-Ref'} {'O2-Ref'} {'11'} {'200' } {'43.995' } {'common'} {'Fp1-Ref'} {'Fp2-Ref'} {'F3-Ref'} {'F4-Ref'} {'C3-Ref'} {'C4-Ref'} {'P3-Ref'} {'P4-Ref'} {'O1-Ref'} {'O2-Ref'} {'12'} {'1000'} {'41.579' } {'common'} {'Fp1-Ref'} {'Fp2-Ref'} {'F3-Ref'} {'F4-Ref'} {'C3-Ref'} {'C4-Ref'} {'P3-Ref'} {'P4-Ref'} {'O1-Ref'} {'O2-Ref'} {'13'} {'200' } {'248.995'} {'common'} {'Fp1-Ref'} {'Fp2-Ref'} {'F3-Ref'} {'F4-Ref'} {'C3-Ref'} {'C4-Ref'} {'P3-Ref'} {'P4-Ref'} {'O1-Ref'} {'O2-Ref'} {'14'} {'200' } {'319.995'} {'common'} {'Fp1-Ref'} {'Fp2-Ref'} {'F3-Ref'} {'F4-Ref'} {'C3-Ref'} {'C4-Ref'} {'P3-Ref'} {'P4-Ref'} {'O1-Ref'} {'O2-Ref'} {'15'} {'200' } {'109.995'} {'common'} {'Fp1-Ref'} {'Fp2-Ref'} {'F3-Ref'} {'F4-Ref'} {'C3-Ref'} {'C4-Ref'} {'P3-Ref'} {'P4-Ref'} {'O1-Ref'} {'O2-Ref'} {'16'} {'200' } {'89.995' } {'common'} {'Fp1-Ref'} {'Fp2-Ref'} {'F3-Ref'} {'F4-Ref'} {'C3-Ref'} {'C4-Ref'} {'P3-Ref'} {'P4-Ref'} {'O1-Ref'} {'O2-Ref'} Columns 15 through 28 {'F7-Ref'} {'F8-Ref'} {'T3-Ref'} {'T4-Ref'} {'T5-Ref'} {'T6-Ref'} {'Fz-Ref'} {'Cz-Ref'} {'Pz-Ref'} {'POL E'} {'POL PG1'} {'POL PG2'} {'A1-Ref'} {'A2-Ref'} {'F7-Ref'} {'F8-Ref'} {'T3-Ref'} {'T4-Ref'} {'T5-Ref'} {'T6-Ref'} {'Fz-Ref'} {'Cz-Ref'} {'Pz-Ref'} {'POL E'} {'POL PG1'} {'POL PG2'} {'A1-Ref'} {'A2-Ref'} {'F7-Ref'} {'F8-Ref'} {'T3-Ref'} {'T4-Ref'} {'T5-Ref'} {'T6-Ref'} {'Fz-Ref'} {'Cz-Ref'} {'Pz-Ref'} {'POL E'} {'POL PG1'} {'POL PG2'} {'A1-Ref'} {'A2-Ref'} {'F7-Ref'} {'F8-Ref'} {'T3-Ref'} {'T4-Ref'} {'T5-Ref'} {'T6-Ref'} {'Fz-Ref'} {'Cz-Ref'} {'Pz-Ref'} {'POL E'} {'POL PG1'} {'POL PG2'} {'A1-Ref'} {'A2-Ref'} {'F7-Ref'} {'F8-Ref'} {'T3-Ref'} {'T4-Ref'} {'T5-Ref'} {'T6-Ref'} {'Fz-Ref'} {'Cz-Ref'} {'Pz-Ref'} {'POL E'} {'POL PG1'} {'POL PG2'} {'A1-Ref'} {'A2-Ref'} {'F7-Ref'} {'F8-Ref'} {'T3-Ref'} {'T4-Ref'} {'T5-Ref'} {'T6-Ref'} {'Fz-Ref'} {'Cz-Ref'} {'Pz-Ref'} {'POL E'} {'POL PG1'} {'POL PG2'} {'A1-Ref'} {'A2-Ref'} {'F7-Ref'} {'F8-Ref'} {'T3-Ref'} {'T4-Ref'} {'T5-Ref'} {'T6-Ref'} {'Fz-Ref'} {'Cz-Ref'} {'Pz-Ref'} {'POL E'} {'POL PG1'} {'POL PG2'} {'A1-Ref'} {'A2-Ref'} {'F7-Ref'} {'F8-Ref'} {'T3-Ref'} {'T4-Ref'} {'T5-Ref'} {'T6-Ref'} {'Fz-Ref'} {'Cz-Ref'} {'Pz-Ref'} {'POL E'} {'POL PG1'} {'POL PG2'} {'A1-Ref'} {'A2-Ref'} {'F7-Ref'} {'F8-Ref'} {'T3-Ref'} {'T4-Ref'} {'T5-Ref'} {'T6-Ref'} {'Fz-Ref'} {'Cz-Ref'} {'Pz-Ref'} {'POL E'} {'POL PG1'} {'POL PG2'} {'A1-Ref'} {'A2-Ref'} {'F7-Ref'} {'F8-Ref'} {'T3-Ref'} {'T4-Ref'} {'T5-Ref'} {'T6-Ref'} {'Fz-Ref'} {'Cz-Ref'} {'Pz-Ref'} {'POL E'} {'POL PG1'} {'POL PG2'} {'A1-Ref'} {'A2-Ref'} {'F7-Ref'} {'F8-Ref'} {'T3-Ref'} {'T4-Ref'} {'T5-Ref'} {'T6-Ref'} {'Fz-Ref'} {'Cz-Ref'} {'Pz-Ref'} {'POL E'} {'POL PG1'} {'POL PG2'} {'A1-Ref'} {'A2-Ref'} {'F7-Ref'} {'F8-Ref'} {'T3-Ref'} {'T4-Ref'} {'T5-Ref'} {'T6-Ref'} {'Fz-Ref'} {'Cz-Ref'} {'Pz-Ref'} {'POL E'} {'POL PG1'} {'POL PG2'} {'A1-Ref'} {'A2-Ref'} {'F7-Ref'} {'F8-Ref'} {'T3-Ref'} {'T4-Ref'} {'T5-Ref'} {'T6-Ref'} {'Fz-Ref'} {'Cz-Ref'} {'Pz-Ref'} {'POL E'} {'POL PG1'} {'POL PG2'} {'A1-Ref'} {'A2-Ref'} {'F7-Ref'} {'F8-Ref'} {'T3-Ref'} {'T4-Ref'} {'T5-Ref'} {'T6-Ref'} {'Fz-Ref'} {'Cz-Ref'} {'Pz-Ref'} {'POL E'} {'POL PG1'} {'POL PG2'} {'A1-Ref'} {'A2-Ref'} {'F7-Ref'} {'F8-Ref'} {'T3-Ref'} {'T4-Ref'} {'T5-Ref'} {'T6-Ref'} {'Fz-Ref'} {'Cz-Ref'} {'Pz-Ref'} {'POL E'} {'POL PG1'} {'POL PG2'} {'A1-Ref'} {'A2-Ref'} {'F7-Ref'} {'F8-Ref'} {'T3-Ref'} {'T4-Ref'} {'T5-Ref'} {'T6-Ref'} {'Fz-Ref'} {'Cz-Ref'} {'Pz-Ref'} {'POL E'} {'POL PG1'} {'POL PG2'} {'A1-Ref'} {'A2-Ref'} Columns 29 through 40 {'POL T1'} {'POL T2'} {'POL X1'} {'POL X2'} {'POL DC01'} {'POL DC02'} {'POL DC03'} {'POL $A1' } {'POL $A2' } {0×0 double} {0×0 double} {0×0 double} {'POL T1'} {'POL T2'} {'POL X1'} {'POL X2'} {'POL DC01'} {'POL DC02'} {'POL DC03'} {'POL $A1' } {'POL $A2' } {0×0 double} {0×0 double} {0×0 double} {'POL T1'} {'POL T2'} {'POL X1'} {'POL X2'} {'POL X3' } {'POL X4' } {'POL DC01'} {'POL DC02'} {'POL DC03'} {'POL DC04'} {'POL $A1' } {'POL $A2' } {'POL T1'} {'POL T2'} {'POL X1'} {'POL X2'} {'POL X3' } {'POL X4' } {'POL DC01'} {'POL DC02'} {'POL DC03'} {'POL DC04'} {'POL $A1' } {'POL $A2' } {'POL T1'} {'POL T2'} {'POL X1'} {'POL X2'} {'POL DC01'} {'POL DC02'} {'POL DC03'} {'POL $A1' } {'POL $A2' } {0×0 double} {0×0 double} {0×0 double} {'POL T1'} {'POL T2'} {'POL X1'} {'POL X2'} {'POL DC01'} {'POL DC02'} {'POL DC03'} {'POL $A1' } {'POL $A2' } {0×0 double} {0×0 double} {0×0 double} {'POL T1'} {'POL T2'} {'POL X1'} {'POL X2'} {'POL DC01'} {'POL DC02'} {'POL DC03'} {'POL $A1' } {'POL $A2' } {0×0 double} {0×0 double} {0×0 double} {'POL T1'} {'POL T2'} {'POL X1'} {'POL X2'} {'POL X3' } {'POL X4' } {'POL DC01'} {'POL DC02'} {'POL DC03'} {'POL DC04'} {'POL $A1' } {'POL $A2' } {'POL T1'} {'POL T2'} {'POL X1'} {'POL X2'} {'POL X3' } {'POL X4' } {'POL DC01'} {'POL DC02'} {'POL DC03'} {'POL DC04'} {'POL $A1' } {'POL $A2' } {'POL T1'} {'POL T2'} {'POL X1'} {'POL X2'} {'POL X3' } {'POL X4' } {'POL DC01'} {'POL DC02'} {'POL DC03'} {'POL DC04'} {'POL $A1' } {'POL $A2' } {'POL T1'} {'POL T2'} {'POL X1'} {'POL X2'} {'POL X3' } {'POL X4' } {'POL DC01'} {'POL DC02'} {'POL DC03'} {'POL DC04'} {'POL $A1' } {'POL $A2' } {'POL T1'} {'POL T2'} {'POL X1'} {'POL X2'} {'POL $A1' } {'POL $A2' } {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {'POL T1'} {'POL T2'} {'POL X1'} {'POL X2'} {'POL $A1' } {'POL $A2' } {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {'POL T1'} {'POL T2'} {'POL X1'} {'POL X2'} {'POL $A1' } {'POL $A2' } {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {'POL T1'} {'POL T2'} {'POL X1'} {'POL X2'} {'POL $A1' } {'POL $A2' } {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {'POL T1'} {'POL T2'} {'POL X1'} {'POL X2'} {'POL $A1' } {'POL $A2' } {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} Columns 41 through 47 {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double} {0×0 double}
"eventually write out the complete lsit to an excel"
writecell(D,'mytable.xlsx')

8 Comments

Oh wow this is is also wonderful, thank you so much Stephen23!!!
... might there be an easy way to remove the '-ref' ending from all channel locations labels in this list?
Thanks again for the above code Its prefect!
JOanne
C={'FP1-Ref', 'FP2-Ref'}
C = 1×2 cell array
{'FP1-Ref'} {'FP2-Ref'}
extractBefore(C,"-Ref")
ans = 1×2 cell array
{'FP1'} {'FP2'}
It does get rid of 'ref! but for some channels, without the '-ref' ending, like '"POL E" ,"POL PG1", "POL PG2"', it replaces those cells with 'missing'
Use endsWith to operate only cells that end with -Ref.
I would use either STRREP or REGEXPREP, which will not replace your data with "missing":
A = ["FP1-Ref", "FP2-Ref", "POL E", "POL PG1", "POL PG2"];
B = strrep(A,'-Ref','')
B = 1×5 string array
"FP1" "FP2" "POL E" "POL PG1" "POL PG2"
B = regexprep(A,'-Ref$','')
B = 1×5 string array
"FP1" "FP2" "POL E" "POL PG1" "POL PG2"
Note that "extracting before something" has no meaning when that something does not exist. In contrast, using the correct functions works as expected.
I just want to say thanks again to both Stephne and Matt, because I'm using things both have taugh me today in my other codes. so much appreciated. And its the little kindnesses that you do in your day that really make a difference in people's lives and jobs.

Sign in to comment.

Products

Release

R2022a

Asked:

on 21 Jun 2023

Edited:

on 22 Jun 2023

Community Treasure Hunt

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

Start Hunting!