How to link two markers in a dataset?

1 次查看(过去 30 天)
I would like to link markers in my dataset for a memory task. We used markers for stimuli, that we converted to numbers 1 to 122 in a column data.markerNames, each followed by a marker that says seen ("gezien") or not seen ("niet gezien") in the dataset. I would like to use a code as underneath:
i = 0;
nLines = numel(Lines);
for cLines = 2:nLines-1
[dat(cLines,:),marker] = FormatNK(Lines{cLines});
if data.markerNames == [1:61]; % && ........; % als nummer 1 - 61 and seen 'gezien'
i = i+1;
result (i) = correctly_recognized;
elseif data.markerNames == [1:61]; % && ....; % als nummer 1 - 61 and not seen 'niet gezien'
i = i + 1;
result (i) = incorrectly_not_recognized;
elseif data.markerNames == [62:122]; % && ...... ; %als nummer 62 - 122 and seen 'gezien'
i = i + 1;
result (i) = incorrectly_recognized;
elseif data.markerNames == [62:122]; % && ...... ; %als nummer 62 - 122 and not seen 'niet gezien'
i = i + 1;
result (i) = correctly_not_recognized;
end
Can we use an index with length(data.markerNames) + 1 or something alike? We're not sure how to proceed. Thank you in advance!

回答(1 个)

Rohit Kulkarni
Rohit Kulkarni 2023-10-13
Hi Naomi,
In my understanding you want to write a code with if and else statements. You can use the following code snippet for doing this task:
i = 0;
nLines = numel(Lines);
for cLines = 2:nLines-1
[dat(cLines,:),marker] = FormatNK(Lines{cLines});
if data.markerNames(cLines) >= 1 && data.markerNames(cLines) <= 61 && strcmp(marker, 'gezien')
i = i+1;
result(i) = correctly_recognized;
elseif data.markerNames(cLines) >= 1 && data.markerNames(cLines) <= 61 && strcmp(marker, 'niet gezien')
i = i + 1;
result(i) = incorrectly_not_recognized;
elseif data.markerNames(cLines) >= 62 && data.markerNames(cLines) <= 122 && strcmp(marker, 'gezien')
i = i + 1;
result(i) = incorrectly_recognized;
elseif data.markerNames(cLines) >= 62 && data.markerNames(cLines) <= 122 && strcmp(marker, 'niet gezien')
i = i + 1;
result(i) = correctly_not_recognized;
end
end
Here "data.markerNames" is used as an index to access the marker names in your dataset. The code snippet above checks if the marker name is between 1 and 61 and is seen (‘gezien’) or not seen (‘niet gezien’).
If the marker name is between 62 and 122 and is seen or not seen, it will be classified as incorrectly recognized or correctly not recognized, respectively.
Please refer to the following link for “strcmp” function documentation:
Hope it helps!

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by