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

  • Thread starter cmajor47
  • Start date
  • Tags
    Box Matlab
In summary, To make the variable 'score' appear after 'Your score was' in the ABC msgbox, you can use the code shown above. This will display a message box with the user's overall TV knowledge and their score. Depending on their score, they will receive a different message.
  • #1
cmajor47
57
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
  • #2
Try this:

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

1. How do I create a message box in MATLAB?

To create a message box in MATLAB, you can use the msgbox function. This function takes in a string as the message and displays it in a pop-up box.

2. Can I customize the appearance of a message box in MATLAB?

Yes, you can customize the appearance of a message box in MATLAB by using additional input arguments in the msgbox function. These arguments allow you to change the title, icon, and buttons of the message box.

3. How can I add multiple lines of text in a message box in MATLAB?

To add multiple lines of text in a message box, you can use the \n escape sequence to create line breaks in your message. Alternatively, you can use the newline function to insert a line break.

4. Is it possible to include variables or data in a message box in MATLAB?

Yes, you can include variables or data in a message box in MATLAB by using string concatenation. For example, if you have a variable x with a value of 5, you can display it in a message box by using msgbox(['The value of x is ', num2str(x)]).

5. Can I create a message box with multiple buttons in MATLAB?

Yes, you can create a message box with multiple buttons in MATLAB by using the msgbox function with the 'modal' argument. This will create a modal message box with the specified buttons, and the code execution will pause until one of the buttons is clicked.

Similar threads

  • Math Proof Training and Practice
2
Replies
67
Views
10K
  • STEM Academic Advising
Replies
25
Views
7K
  • Programming and Computer Science
Replies
10
Views
3K
  • STEM Academic Advising
Replies
16
Views
4K
  • General Discussion
Replies
14
Views
4K
  • General Discussion
2
Replies
65
Views
8K
Replies
109
Views
54K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
2K
Back
Top