Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
Emily Belleau
Emily Belleau el 26 de Oct. de 2016
Editada: Guillaume el 27 de Oct. de 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

Respuestas (2)

Alexandra Harkai
Alexandra Harkai el 27 de Oct. de 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 el 27 de Oct. de 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

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by