How to Display the Score in MATLAB Message Box for Your TV Knowledge

  • Thread starter Thread starter cmajor47
  • Start date Start date
  • Tags Tags
    Box Matlab
AI Thread Summary
To display the score in a MATLAB message box, the variable 'score' can be concatenated with the message string using the num2str function. The code snippet provided demonstrates how to create a message box that includes the score after the text "Your score was". Depending on the total score calculated from variables A, B, and C, different messages can be shown to indicate the user's TV knowledge level. The message box will dynamically display the score based on the user's input. This approach effectively communicates the user's performance in a clear and informative manner.
cmajor47
Messages
53
Reaction score
0

Homework Statement


In the ABC msgbox I would like the variable 'score' to appear after 'Your score was'. How do I do this?


Homework Equations


%tells the user their overall tv knowledge
score=A+B+C;
title1='Your TV Knowledge';
if ((A+B+C)<=24)&&((A+B+C)>=18)
ABC=msgbox('You are a tv expert. Your score was ');
elseif ((A+B+C)<18)&&((A+B+C)>=9)
ABC=msgbox('You know a lot about your favorite shows, but don''t know that much about others. Your score was ');
elseif ((A+B+C)<9)&&((A+B+C)>=0)
ABC=msgbox('You rarely watch tv. You need to brush up on your tv knowledge. Your score was ');
end
 
Physics news on Phys.org
Try this:

ABC = msgbox(['You are a tv expert. Your score was ', num2str( score )] );
 

Similar threads

2
Replies
67
Views
14K
Replies
25
Views
8K
Replies
14
Views
4K
Replies
65
Views
10K
Replies
7
Views
3K
Replies
7
Views
4K
Replies
7
Views
3K
Back
Top