Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
comparing/evaluating string input

Subject: comparing/evaluating string input

From: Jordan Rodger

Date: 28 Mar, 2011 22:45:09

Message: 1 of 2

hey there,

basically i'm running a simple psychological experiment on matlab as part of some coursework and i'm brand new to the program.

the short and sweet of it is that I want to compare the input of participants (it will be a string - a word which is the pair of a word they have memorised o response 'NO' if the word is not one they memorised) and then I want to compare this to the word they should have said, or the 'NO' response they should have said. It will be across 10 trials and I need to be able to record whether responses were correct or not, in the form 1 and 0 would be good so I can calculate an average etc... Here's the section of the script anyway...

disp(a)
fprintf('Remember the above word pairs - press the spacebar when have memorised them\n')
pause
for trial=1
    fprintf('the following word may or may not have been presented earlier with a pair word\n')
    disp('WHISPER');
    fprintf('Type the word pair that the word was memorised with, or type NO if it was not present earlier. \n please type in capitals\n')
    answer=input('', 's');
    STRCMP(answer, 'NO')
end

I get this error message "??? Undefined function or method 'STRCMP' for input arguments of type 'char'"

For this trial the 'NO' response would be correct as the word was not see before. At first I had:
if answer=='NO'
   s=1
else
   s=0

But this did not work for incorrect answers - i.e. if I reported a word instead of correctly responding 'NO'. (error message - ??? Error using ==> eq
Matrix dimensions must agree.)

 I haven't been taught to use the STRCMP command but played around and so I might be missing something really obvious.

Thanks in advance for help and obvoiusly ask for more info if need

Jord

Subject: comparing/evaluating string input

From: Florin Neacsu

Date: 5 Apr, 2011 00:03:05

Message: 2 of 2

"Jeremy Fisher" wrote in message <imr31k$jg1$1@fred.mathworks.com>...
> hey there,
>
> basically i'm running a simple psychological experiment on matlab as part of some coursework and i'm brand new to the program.
>
> the short and sweet of it is that I want to compare the input of participants (it will be a string - a word which is the pair of a word they have memorised o response 'NO' if the word is not one they memorised) and then I want to compare this to the word they should have said, or the 'NO' response they should have said. It will be across 10 trials and I need to be able to record whether responses were correct or not, in the form 1 and 0 would be good so I can calculate an average etc... Here's the section of the script anyway...
>
> disp(a)
> fprintf('Remember the above word pairs - press the spacebar when have memorised them\n')
> pause
> for trial=1
> fprintf('the following word may or may not have been presented earlier with a pair word\n')
> disp('WHISPER');
> fprintf('Type the word pair that the word was memorised with, or type NO if it was not present earlier. \n please type in capitals\n')
> answer=input('', 's');
> STRCMP(answer, 'NO')
> end
>
> I get this error message "??? Undefined function or method 'STRCMP' for input arguments of type 'char'"
>
> For this trial the 'NO' response would be correct as the word was not see before. At first I had:
> if answer=='NO'
> s=1
> else
> s=0
>
> But this did not work for incorrect answers - i.e. if I reported a word instead of correctly responding 'NO'. (error message - ??? Error using ==> eq
> Matrix dimensions must agree.)
>
> I haven't been taught to use the STRCMP command but played around and so I might be missing something really obvious.
>
> Thanks in advance for help and obvoiusly ask for more info if need
>
> Jord

Hi,

I only briefly read your post and noticed this so I do not know if you have other problems too.

There was a few days ago a similar post dealing with the same error.
You need to write strcmp, with lower case and not STRCMP.

Regards,
Florin

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us