I´d like to find some variables and concatenate their values in a single array. These variables share the start of their name (false_onsets_). Things get complicated because for each subject in my experiment, the variables may or may not exist. So I want to concatenate all variables that exist.
To create the variables (false_onsets_), I use the following code:
if ~isempty(listen_false_index) for ii=1:length(listen_false_index) false_onsets_lis (1,ii)=onsets{1,1} (1,listen_false_index(ii)); end false_duration_lis=zeros(1,length(listen_false_index)); end if ~isempty(sing_along_false_index) for jj=1:length(sing_along_false_index) false_onsets_singa(1,jj)=onsets{1,1} (1,sing_along_false_index(jj)); end false_duration_singa=zeros(1,length(sing_along_false_index)); end if ~isempty(sing_memo_false_index) for kk=1:length(sing_memo_false_index) false_onsets_singm(1,kk)=onsets{1,1} (1,sing_memo_false_index(kk)); end false_duration_singm=zeros(1,length(sing_memo_false_index)); end if ~isempty(baseline_false_index) for ll=1:length(baseline_false_index) false_onsets_base(1,ll)=onsets{1,1} (1,baseline_false_index(ll)); end false_duration_base=zeros(1,length(baseline_false_index)); end
I tried using who but this just creates a cell with the names of the variables and not its value.
Any alternative idea for how this could be achieved?
Thank you in advance.
Best, Noelia
Best Answer