Input - Output dialog commands and boxes



Similar documents
GUI Input and Output. Greg Reese, Ph.D Research Computing Support Group Academic Technology Services Miami University

MATLAB GUIs. We conclude our brief overview of MATLAB by looking at : Brief introduction to MATLAB GUI building. Back Close CM0268 MATLAB DSP GRAPHICS

2Creating Reports: Basic Techniques. Chapter

MATLAB 7 Creating Graphical User Interfaces

Appendix K Introduction to Microsoft Visual C++ 6.0

Introduction to Graphical User Interface (GUI) MATLAB 6.5

Recording Supervisor Manual Presence Software

Windows XP Pro: Basics 1

Introduction. Chapter 1

Call Recorder Oygo Manual. Version

In this session, we will explain some of the basics of word processing. 1. Start Microsoft Word 11. Edit the Document cut & move

Handout: Word 2010 Tips and Shortcuts

BIGPOND ONLINE STORAGE USER GUIDE Issue August 2005

Bitrix Site Manager 4.0. Quick Start Guide to Newsletters and Subscriptions

Merging Labels, Letters, and Envelopes Word 2013

Migrating to Excel 2010 from Excel Excel - Microsoft Office 1 of 1

Document Management Quick Reference Guide

Sample Table. Columns. Column 1 Column 2 Column 3 Row 1 Cell 1 Cell 2 Cell 3 Row 2 Cell 4 Cell 5 Cell 6 Row 3 Cell 7 Cell 8 Cell 9.

Create a New Database in Access 2010

Using Flow Control with the HEAD Recorder

KPN SMS mail. Send SMS as fast as !

Inteset Secure Lockdown ver. 2.0

CNCTRAIN OVERVIEW CNC Simulation Systems

Beginner s Matlab Tutorial

User s Guide for Polycom HDX Systems

NØGSG DMR Contact Manager

Getting Started Using AudibleManager. AudibleManager 5.0

Key Connected Office Voice User Reference Guide

ICP Data Entry Module Training document. HHC Data Entry Module Training Document

Vodafone PC SMS (Software version 4.7.1) User Manual

3. (1.0 point) To ungroup worksheets, you can click a sheet of a sheet not in the group. a. index b. panel c. tab d. pane

State of Michigan Data Exchange Gateway. Web-Interface Users Guide

AN INTRODUCTION TO STAROFFICE WRITER

managedip SIP, PRI and Essentials

Microsoft Access 2010 Part 1: Introduction to Access

FINACS INVENTORY Page 1 of 9 INVENTORY TABLE OF CONTENTS. 1. Stock Movement Physical Stock Adjustment...7. (Compiled for FINACS v 2.12.

BusinessObjects: General Report Writing for Version 5

Using Adobe Dreamweaver CS4 (10.0)

Cisco Dial Plan. Feature and Session Buttons. Your Phone

Agent Tasks. Dial from Directory 1. In the Content panel, select the target directory. 2. Click the phone number you want to call.

Nintex Forms 2013 Help

Fleet Manager II. Operator Manual

How do I share a file with a friend or trusted associate?

Scan to PC Desktop: Image Retriever 5.2 for Xerox WorkCentre C2424

Update: About Apple RAID Version 1.5 About this update

Introduction. POP and IMAP Servers. MAC1028 June 2007

DiskPulse DISK CHANGE MONITOR

Macros in Word & Excel

Advanced Client Phone Training

MATLAB. Creating Graphical User Interfaces Version 6. The Language of Technical Computing. Computation. Visualization. Programming

Everyday Excel Stuff Excel Day Planner Organizer Reference Guide

Move between open workbooks. Display the print menu. Select whole spreadsheet. Microsoft Excel Keyboard Keys. General

USB Recorder User Guide

UM8000 MAIL USER GUIDE

Lotus Notes Client Version 8.5 Reference Guide

Business e-cash Manager Plus Automated Clearing House (ACH)

USB Recorder. User s Guide. Sold by: Toll Free: (877)

Introduction to Matlab

BulkSMS Text Messenger Product Manual

SCATS. EDI File Verification. User Manual

Impact Call PC. call001. Impact Call User s Guide

CHAPTER 6: SEARCHING AN ONLINE DATABASE

CNC Transfer. Operating Manual

KEYBOARD SHORTCUTS. Note: Keyboard shortcuts may be different for the same icon depending upon the SAP screen you are in.

Version 1.5 Satlantic Inc.

FirstClass FAQ's An item is missing from my FirstClass desktop

MATLAB Functions. function [Out_1,Out_2,,Out_N] = function_name(in_1,in_2,,in_m)

Switching from PC SAS to SAS Enterprise Guide Zhengxin (Cindy) Yang, inventiv Health Clinical, Princeton, NJ

PLAY VIDEO. Close- Closes the file you are working on and takes you back to MicroStation V8i Open File dialog.

Microsoft Migrating to PowerPoint 2010 from PowerPoint 2003

Microsoft Word 2010 Prepared by Computing Services at the Eastman School of Music July 2010

All Tech Notes and KBCD documents and software are provided "as is" without warranty of any kind. See the Terms of Use for more information.

WS_FTP Professional 12

Tutorial 3 Maintaining and Querying a Database

Access Tutorial 3 Maintaining and Querying a Database. Microsoft Office 2013 Enhanced

Business Digital Voice My Features My Numbers

Audacity Sound Editing Software

Unified Messaging. User Guide

Technical Documentation Version 6.7. Slots

Chapter 9 Telephone Conferencing

How to test and debug an ASP.NET application

Welcome to Ipswitch Instant Messaging

NovaBACKUP. User Manual. NovaStor / November 2011

Nokia Internet Modem User Guide

Right-click the Start button and select Properties. Click the Customize button and choose from the options displayed:

The Application Getting Started Screen is display when the Recruiting Matrix 2008 Application is Started.

Appointment Scheduler

PaymentNet Federal Card Solutions Cardholder FAQs

BCSD WebMail Documentation

EMC Documentum Webtop

Downloading <Jumping PRO> from Page 2

Microsoft Migrating to Word 2010 from Word 2003

Context-sensitive Help Guide

Business Objects Version 5 : Introduction

Part 2. Copyright 1998 Philips Consumer Communications L.P. All rights reserved. Printed in Mexico. Issue 1AT&T

Create Database Tables 2

**Web mail users: Web mail provides you with the ability to access your via a browser using a "Hotmail-like" or "Outlook 2003 like" interface.

3 IDE (Integrated Development Environment)

Windows XP File Management

Transcription:

input Request user input user_entry = input('prompt') user_entry = input('prompt', 's') Input - Output dialog commands and boxes The response to the input prompt can be any MATLAB expression, which is evaluated using the variables in the current workspace. Remarks user_entry = input('prompt') displays prompt as a prompt on the screen, waits for input from the keyboard, and returns the value entered in user_entry. user_entry = input('prompt', 's') returns the entered string as a text variable rather than as a variable name or numerical value. If you press the Return key without entering anything, input returns an empty matrix. The text string for the prompt can contain one or more '\n' characters. The '\n' means to skip to the next line. This allows the prompt string to span several lines. To display just a backslash, use '\\'. If you enter an invalid expression at the prompt, MATLAB displays the relevant error message and then prompts you again to enter input. Examples Press Return to select a default value by detecting an empty matrix: reply = input('do you want more? Y/N [Y]: ', 's'); if isempty(reply) reply = 'Y'; else reply = upper(reply); end disp(reply); reply = input('pierwszy wiersz \n Drugi wiersz\n Y/N [Y]: ', 's'); if isempty(reply) reply = 'Y'; else reply = upper(reply); end disp(reply);

inputdlg Create and open input dialog box answer = inputdlg(prompt) creates a modal dialog box and returns user input. answer = inputdlg('prompt'); answer_num = str2num(answer{1}); disp(answer); disp(answer_num); For multiple prompts in the cell array. prompt is a cell array containing prompt strings. answer = inputdlg({'prompt1', 'prompt2', 'prompt3'}); for i=1:3 answer_num(i) = str2num(answer{i}); end; disp(answer_num'); answer = inputdlg(prompt,dlg_title) dlg_title specifies a title for the dialog box. answer = inputdlg({'prompt1', 'prompt2', 'prompt3'}, 'Tytuł okna dialogowego'); for i=1:3 answer_num(i) = str2num(answer{i}); end; disp(answer_num ); answer = inputdlg(prompt,dlg_title,num_lines) num_lines specifies the number of lines for each value. If num_lines is a scalar, it applies to all prompts. If num_lines is a column vector, each element specifies the number of lines of input for a prompt. answer = inputdlg({'prompt1', 'prompt2', 'prompt3'}, 'Tytuł okna dialogowego', 2); for i=1:3 answer_num(i) = str2num(answer{i}); end; disp(answer_num); answer = inputdlg(prompt,dlg_title,num_lines,defans) defans specifies the default value to display for each prompt. defans must contain the same number of elements as prompt and all elements must be strings. prompt_tab = {'prompt1', 'prompt2', 'prompt3'}; start_value_tab = {'111', '222', '333'}; answer = inputdlg(prompt_tab, 'Tytuł okna dialogowego', 2, start_value_tab); for i=1:3 answer_num(i) = str2num(answer{i}); end; disp(answer_num);

answer = inputdlg(prompt, dlg_title, num_lines, defans, options) If options is the string 'on', the dialog is made resizable in the horizontal direction. If options is a structure, the fields shown in the following table are recognized: Field Resize WindowStyle Interpreter Can be 'on' or 'off' (default). If 'on', the window is resizable horizontally. Can be either 'normal' or 'modal' (default). Can be either 'none' (default) or 'tex'. If the value is 'tex', the prompt strings are rendered using LaTeX. prompt_tab = {'prompt1', 'prompt2', 'prompt3'}; start_value_tab = {'111', '222', '333'}; options.resize='on'; answer = inputdlg(prompt_tab, 'Tytuł okna dialogowego', 2, start_value_tab, options); for i=1:3 answer_num(i) = str2num(answer{i}); end; disp(answer_num); If the user clicks the Cancel button to close an inputdlg box, the dialog returns an empty cell array: answer = {}

msgbox Create and open message box h = msgbox(message) h = msgbox(message,title) h = msgbox(message,title,icon) h = msgbox(message,title,'custom',icondata,iconcmap) h = msgbox(...,createmode) h = msgbox(message) creates a message dialog box that automatically wraps Message to fit an appropriately sized figure. Message is a string vector, string matrix, or cell array. msgbox returns the handle of the message box in h. h = msgbox(message,title) specifies the title of the message box. h = msgbox(message,title,icon) specifies which icon to display in the message box. Icon is 'none', 'error', 'help', 'warn', or 'custom'. The default is 'none'. Message = 'Wiadomość'; Title = 'Tytuł' Icon = 'help'; h = msgbox(message,title,icon); h = msgbox(message,title,'custom',icondata,iconcmap) defines a customized icon. IconData contains image data defining the icon. IconCMap is the colormap used for the image. h = msgbox(...,createmode) specifies whether the message box is modal or nonmodal. Optionally, it can also specify an interpreter for Message and Title. If CreateMode is a string, it must be one of the values shown in the following table. CreateMode Value 'modal' 'non-modal' (default) 'replace' Replaces the message box having the specified Title, that was last created or clicked on, with a modal message box as specified. All other message boxes with the same title are deleted. The message box which is replaced can be either modal or nonmodal. Creates a new nonmodal message box with the specified parameters. Existing message boxes with the same title are not deleted. Replaces the message box having the specified Title, that was last created or clicked on, with a nonmodal message box as specified. All other message boxes with the same title are deleted. The message box which is replaced can be either modal or nonmodal.

If CreateMode is a structure, it can have fields WindowStyle and Interpreter. The WindowStyle field must be one of the values in the table above. Interpreter is one of the strings'tex' or 'none'. The default value for Interpreter is 'none'. questdlg Create and open question dialog box button = questdlg('qstring') button = questdlg('qstring','title') button = questdlg('qstring','title',default) button = questdlg('qstring','title','str1','str2',default) button = questdlg('qstring','title','str1','str2','str3',default) button = questdlg('qstring','title',..., options) button = questdlg('qstring') displays a modal dialog box presenting the question 'qstring'. The dialog has three default buttons, Yes, No, and Cancel. If the user presses one of these three buttons, button is set to the name of the button pressed. If the user presses the close button on the dialog without making a choice, button is set to the empty string. If the user presses the Return key, button is set to 'Yes'. 'qstring' is a cell array or a string that automatically wraps to fit within the dialog box. Example 1 button = questdlg('qstring','title') displays a question dialog with 'title' displayed in the dialog's title bar. button = questdlg('qstring','title',default) specifies which push button is the default in the event that the Return key is pressed. 'default' must be 'Yes', 'No', or 'Cancel'. button = questdlg('qstring','title','str1','str2',default) creates a question dialog box with two push buttons labeled 'str1' and 'str2'. default specifies the default button selection and must be 'str1' or 'str2'. button = questdlg('qstring','title','str1','str2','str3',default) creates a question dialog box with three push buttons labeled 'str1', 'str2', and 'str3'. default specifies the default button selection and must be 'str1', 'str2', or 'str3'. When default is specified, but is not set to one of the button names, pressing the Enter key displays a warning and the dialog remains open. button = questdlg('qstring','title',..., options) replaces the string default with a structure, options. The structure specifies which button string is the default answer, and whether to use TeX to interpret the question string, qstring. Button strings and dialog titles cannot use TeX interpretation. The options structure must include the fields Default and Interpreter, both strings. It can include other fields, but questdlg does not use them. You can set Interpreter to 'none' or 'tex'. If the Default field does not contain a valid button name, a command window warning is issued and the dialog box does not respond to pressing the Enter key. Create a dialog that requests a dessert preference and encode the resulting choice as an integer. % Construct a questdlg with three options choice = questdlg('please choose a dessert:', 'Dessert Menu', 'Ice cream', 'Cake', 'No thank you', 'No thank you'); % Handle response switch choice case 'Ice cream'

disp([choice ' coming right up.']) dessert = 1; break case 'Cake' disp([choice ' coming right up.']) dessert = 2; break case 'No thank you' disp('i''ll bring you your check.') dessert = 0; end The case statements can contain white space but are case-sensitive. pause Halt execution temporarily pause pause(n) pause on pause, by itself, causes the currently executing M-file to stop and wait for you to press any key before continuing. Pausing must be enabled for this to take effect. pause(n) pauses execution for n seconds before continuing, where n can be any nonnegative real number. The resolution of the clock is platform specific. A fractional pause of 0.01 seconds should be supported on most platforms. Pausing must be enabled for this to take effect. keyboard Input from keyboard keyboard keyboard, when placed in an M-file, stops execution of the file and gives control to the keyboard. The special status is indicated by a K appearing before the prompt. You can examine or change variables; all MATLAB commands are valid. This keyboard mode is useful for debugging your M-files.. To terminate the keyboard mode, type the command return then press the Return key.

uigetfile Open standard dialog box for retrieving files uigetfile [FileName,PathName,FilterIndex] = uigetfile(filterspec) [FileName,PathName,FilterIndex] = uigetfile(filterspec,dialogtitle) [FileName,PathName,FilterIndex] = uigetfile(filterspec,dialogtitle,defaultname) [FileName,PathName,FilterIndex] = uigetfile(...,'multiselect',selectmode) uigetfile displays a modal dialog box that lists files in the current directory and enables the user to select or type the name of a file to be opened. If the filename is valid and if the file exists, uigetfile returns the filename when the user clicks Open. Otherwise uigetfile displays an appropriate error message from which control returns to the dialog box. The user can then enter another filename or click Cancel. If the user clicks Cancel or closes the dialog window, uigetfile returns 0. If FilterSpec is a string that contains a filename, the filename is displayed and selected in the File name field and the file's extension is used as the default filter. If FilterSpec is a cell array of strings, the first column contains a list of file extensions. The optional second column contains a corresponding list of descriptions. These descriptions replace standard descriptions in the Files of type field. A description cannot be an empty string. If FilterSpec is not specified, uigetfile uses the default list of file types (i.e., all MATLAB files). After the user clicks Open and if the filename exists, uigetfile returns the name of the file in FileName and its path in PathName. If the user clicks Cancel or closes the dialog window, FileName and PathName are set to 0. FilterIndex is the index of the filter selected in the dialog box. Indexing starts at 1. If the user clicks Cancel or closes the dialog window, FilterIndex is set to 0. [FileName,PathName,FilterIndex] = uigetfile(...,'multiselect',selectmode) sets the multiselect mode to specify if multiple file selection is enabled for the uigetfile dialog. Valid values for selectmode are 'on' and 'off' (default). If 'MultiSelect' is 'on' and the user selects more than one file in the dialog box, then FileName is a cell array of strings, each of which represents the name of a selected file. Filenames in the cell array are in the sort order native to your platform. Because multiple selections are always in the same directory, PathName is always a string that represents a single directory. Example 1 The following statement displays a dialog box that enables the user to retrieve a file. The statement lists all MATLAB M- files within a selected directory. The name and path of the selected file are returned in FileName and PathName. Note that uigetfile appends All Files(*.*) to the file types when FilterSpec is a string. [FileName,PathName] = uigetfile('*.m','select the M-file');

Example 2 To create a list of file types that appears in the Files of type list box, separate the file extensions with semicolons, as in the following code. Note that uigetfile displays a default description for each known file type, such as "Simulink Models" for.mdl files. [filename, pathname] = uigetfile({'*.m';'*.mdl';'*.mat';'*.*'},'file Selector'); Example 3 If you want to create a list of file types and give them descriptions that are different from the defaults, use a cell array, as in the following code. This example also associates multiple file types with the 'MATLAB Files' description. [filename, pathname] = uigetfile(... {'*.m;*.fig;*.mat;*.mdl','matlab Files (*.m,*.fig,*.mat,*.mdl)'; '*.m', 'M-files (*.m)';... '*.fig','figures (*.fig)';... '*.mat','mat-files (*.mat)';... '*.mdl','models (*.mdl)';... '*.*', 'All Files (*.*)'},... 'Pick a file'); The first column of the cell array contains the file extensions, while the second contains the descriptions you want to provide for the file types. Note that the first entry of column one contains several extensions, separated by semicolons, all of which are associated with the description 'MATLAB Files (*.m,*.fig,*.mat,*.mdl)'. The code produces the dialog box shown in the following figure.

Example 4 The following code checks for the existence of the file and displays a message about the result of the open operation. [filename, pathname] = uigetfile('*.m', 'Pick an M-file'); if isequal(filename,0) disp('user selected Cancel') else disp(['user selected', fullfile(pathname, filename)]) end Example 5 This example creates a list of file types and gives them descriptions that are different from the defaults, then enables multiple file selection. The user can select multiple files by holding down the Shift or Ctrl key and clicking on a file. [filename, pathname, filterindex] = uigetfile(... { '*.mat','mat-files (*.mat)';... '*.mdl','models (*.mdl)';... '*.*', 'All Files (*.*)'},... 'Pick a file',... 'MultiSelect', 'on'); sound Play vector as sound. SOUND(Y,FS) sends the signal in vector Y (with sample frequency FS) out to the speaker on platforms that support sound. Values in Y are assumed to be in the range -1.0 <= y <= 1.0. Values outside that range are clipped. Stereo sounds are played, on platforms that support it, when Y is an N-by-2 matrix. SOUND(Y) plays the sound at the default sample rate of 8192 Hz. Example: load handel sound(y,fs) You should hear a snippet of Handel's Hallelujah Chorus.