Error: Undefined operator '-' for input arguments of type 'cell'.
조회 수: 1 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (2개)
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])
댓글 수: 0
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!