Error: Undefined operator '-' for input arguments of type 'cell'.

1 Ansicht (letzte 30 Tage)
Emily Belleau
Emily Belleau am 26 Okt. 2016
Bearbeitet: Guillaume am 27 Okt. 2016
Hello Matlab experts,
I am trying to subtract 6 secs off of the onset times that I have extracted from an excel file. I now have a series of vectors with the onset times (just a column of numbers) saved in .mat files. I am running into an Error: Undefined operator '-' for input arguments of type 'cell'. I just used the following code:
neutral_cue_onset_time_adjusted=neutral_cue_onset_time-6;
save ('neutral_cue_onset_time_adjusted.mat', 'neutral_cue_onset_time_adjusted');
The previous code I used to find and extract onset times was:
[num,txt,raw] = xlsread ('Placebo_MID_Reward_PLAEGO002_session1_Neutral.xlsx');
% Extract all cue-type onset times
cue_type=raw(:,7);
cue_block_onset=raw(:,9);
neutral_index=find(strcmp(cue_type(:),'neutral'));
neutral_cue_onset_time=cue_block_onset(neutral_index);
save ('neutral_cue_onset_time.mat', 'neutral_cue_onset_time');
I would appreciate any guidance!
Emily

Antworten (2)

Alexandra Harkai
Alexandra Harkai am 27 Okt. 2016
If you want to preserve the shape of your cell array neural_cue_onset_time, you can convert the cells to the underlying data type, subtract 6, then back to the proper shape of cell array:
neutral_cue_onset_time_adjusted = mat2cell(cell2mat(neutral_cue_onset_time)-6, [dim1, dim2])

Greg Heath
Greg Heath am 27 Okt. 2016
Cut and paste into the command line
a = 10, b=5
A = num2cell(a)
B = num2cell(b)
c = b-a
C = gsubtract(B,A)
C = B-A
Hope this helps.
Thank you for formally accepting my answer
Greg

Community Treasure Hunt

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

Start Hunting!

Translated by