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
Click For Summary
SUMMARY

The discussion focuses on displaying a variable 'score' in a MATLAB message box. The user seeks to append the score to a predefined message indicating their TV knowledge level. The solution involves using the 'num2str' function to convert the score into a string format and concatenate it with the message. The final code snippet provided is: ABC = msgbox(['You are a tv expert. Your score was ', num2str(score)]);, which effectively displays the score in the message box.

PREREQUISITES
  • Basic understanding of MATLAB programming
  • Familiarity with MATLAB message boxes
  • Knowledge of string concatenation in MATLAB
  • Understanding of conditional statements in MATLAB
NEXT STEPS
  • Explore MATLAB string manipulation functions
  • Learn about MATLAB conditional statements and their applications
  • Investigate advanced features of MATLAB message boxes
  • Study data visualization techniques in MATLAB for displaying scores
USEFUL FOR

This discussion is beneficial for MATLAB programmers, educators creating interactive quizzes, and anyone interested in enhancing user feedback through message boxes in MATLAB applications.

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

  • · Replies 67 ·
3
Replies
67
Views
16K
  • · Replies 25 ·
Replies
25
Views
8K
  • · Replies 10 ·
Replies
10
Views
4K
  • · Replies 16 ·
Replies
16
Views
5K
  • · Replies 65 ·
3
Replies
65
Views
12K
  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 7 ·
Replies
7
Views
4K