MATLAB Program structure: Sequential structure "1"
Source: Internet
Author: User
Sequential structure: Execute commands sequentially, generally involving data input, data calculation or processing, data output and so on.
1. Data entry:Function:
inputPrompt for user input. The left side of the equation
valueCase
NUM = input (PROMPT)Form one: A=input (' Value of input variable a '); After execution, scree display: Enter the value of the variable A, enter the value and return, the value of a is saved to the variable A; form two: A=input (' input matrix A '); after execution, scree display: input into matrix A; Enter and return, the matrix is saved to A; the left side of the equation is
stringCase
STR = input (PROMPT, ' s ')Returns the entered text as a MATLAB string, without evaluating expressions. Form: name=input (' What ' s your name? ', ' s '); After execution, scree shows: What's your name?; After entering the character, the character is saved to the name; Note: Prompt:use ' \ n ' to indicate Eachnew line. Contains a backslash: ' \ \ ', containing ' way: ';
Example: reply = input (' Does want more? y/n [Y]: ', ' s '); If IsEmpty (reply) Reply = ' Y '; End If the prompt does not enter any value, then reply=y;
2. Output of the dataFunction:
disp (output Item)The DISP function does not display the matrix name if the output item in the base is either a string or a matrix. Form one: a= ' Hello,tom '; Disp (A); Output: Hello,tom form two: a=[1,2,3;4,5,6;7,8,9] disp (A); output: 1 2 3 4 5 6 7 8 9
3. Program Pause function: Pause (delay number of seconds) such as direct pause, will be paused until after pressing any key to continue to run; the execution of the program can press: CTRL + C can be used to view the program rub the results or view the output graphics;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.