Using MATLAB. Please pay attention to the (Restrictions), because the assessment
ID: 2292453 • Letter: U
Question
Using MATLAB. Please pay attention to the (Restrictions), because the assessment will be incorrect!?
Lie detector output converter An existing lie detector function returns a string "truth" or "lie" based on the result a question posed. Write a function called OutputConverter that accepts either a string scalar or a character vector, and assigns a numeric 1 if "truth", either in upper or lower case, is returned. Otherwise, assign the numeric value o >> testvalue = OutputConverter( 'truth') testValue logical testvalue logical = OutputConverter("truth") >> testValue Your Function 1 function testValueOutputConverter(userResult) 3%Compare the string to be truth. 5 if strcmp(userResult, 'truth Save C Reset MATLAB Documentation %Update the value of testvalue. testvalue = 1; 12 13 else 14 16 %Update the value of testvalue. 19 testvalue = 0; 21 %End of the if condition. 23 endExplanation / Answer
Matlab Script:
function testValue = OutputConverter(userResult)
userResult=lower(userResult);%converts given result into lower case
if strcmp(userResult,'truth') || strcmp(userResult,"truth")
testValue= true;
else
testValue= false;
end
end
output:
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.