Question

I actually have 2 queries:

  1. How do I display the data of a variable in a msgbox? In other words, if I have dist=3765 at the end of my program and I want to display it in a msgbox, how do I do it?

  2. I want the user to select an input file (suppose an image) from a folder in my MATLAB program using an explorer window at runtime. How do I code that in MATLAB, or is there an existing function available for it?

Was it helpful?

Solution

You should check out these MathWorks blog posts (here and here) from Ken and Mike discussing all of the dialog boxes that you can use in MATLAB. The specific dialog boxes that address the needs listed in your question would be:

  • MSGBOX, which will display a message. You first have to create a string to use as a message. For example, if you have a variable dist that stores an integer value you want to display, you can do the following (using the function INT2STR):

    hMessage = msgbox(['dist = ' int2str(dist)]);
    

    alt text

  • UIGETFILE, which opens a dialog box for selecting a file and returns the file name and path selected. For example, the following opens up a dialog box to select a MATLAB file (*.m, *.fig, *.mat, etc.) from the current directory:

    [fileName,filePath] = uigetfile();
    

    alt text

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top