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

1 回表示 (過去 30 日間)
Emily Belleau
Emily Belleau 2016 年 10 月 26 日
編集済み: Guillaume 2016 年 10 月 27 日
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

回答 (2 件)

Alexandra Harkai
Alexandra Harkai 2016 年 10 月 27 日
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 2016 年 10 月 27 日
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

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by