How to link two markers in a dataset?
1 view (last 30 days)
Show older comments
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!
0 Comments
Answers (1)
Rohit Kulkarni
on 13 Oct 2023
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!
0 Comments
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!