How do I filter time data from excel columns, where the values are numerical and the columns are character named?

1 view (last 30 days)
Hello,
I'm trying to create a code that will filter eyelink fixations (labeled IA_FIRST_SACCADE_START_TIME) that took place before the stimulus onset (time). I've tried creating a variable that will only use the columns I need (6 and 8) like so
fixation = raw(6:8)
but it only outputs an array of 3 12s like so
[{12} {12} {12}]
I also tried creating a for loop as
for (i=='time'> 0) in raw %there was a stimulus present
if (i== 'time'> 0)
for ('IA_FIRST_SACCADE_START_TIME'> 'time')
add('IA_FIRST_SACCADE_START_TIME', fixations)
end
end
but I get the error for invalid use of operator
Finally, I've tried creating an indexed variable like
data=raw('time'>=0 && ('FIRST_SACCADE_START_TIME'>='time'==||));
but that comes out with another invalid use of operator error too
What should I do to make this work? Any help at all would be appreciated

Accepted Answer

Simon Chan
Simon Chan on 16 Jul 2021
Edited: Simon Chan on 16 Jul 2021
Better to look at the usage of those data import function used in MATLAB.
I use readcell in this case.
rawdata=readcell('RES_IAS (1).xlsx'); % Use readcell to read all data
data=rawdata(:,6:8); % Extract 6th to 8th column
header = rawdata(1,6:8); % Extract the headers
Start_time = cell2mat(data(2:end,1)); % Convert to a matrix for data in column 6
time = cell2mat(data(2:end,3)); % Convert to a matrix for data in column 8
idx1=Start_time>time; % Find index for Start_time > time
result = [Start_time(idx1) time(idx1)]; % This is the result you may want in matrix form
plot(Start_time(idx1)) % Plot the Start_time
hold on
plot(time(idx1)) % Plot the time
legend(header{1},header{3}) % Legend
  3 Comments

Sign in to comment.

More Answers (0)

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by