MATLAB, and what types of add-on application-specific solutions are available in MATLAB toolboxes. MATLAB Documentation (p. 1-4) Find out where to look for instruction on how to use each component of MATLAB, and where to find help when you need it. Starting and Quitting MATLAB (p. 1-6) Start a new MATLAB session, use the desktop environment. MATLAB MATLAB is a software package for doing numerical computation. It was originally designed for solving linear algebra type problems using matrices. It’s name is derived from MATrix LABoratory. MATLAB has since been expanded and now has built-in functions for solving problems requiring data analysis, signal.
- Matlab Example Programrubackup Python
- Matlab Example Programs
- Matlab Example Programrubackup Function
- Matlab Example Programrubackup Method
![Programrubackup Programrubackup](/uploads/1/0/7/0/107059677/894192127.jpg)
Package Apps From the MATLAB Toolstrip
You can package any MATLAB® app you create into a single file that can be easily shared with others. When you package an app, MATLAB creates a single app installation file (
.mlappinstall
). The installation file enables you and others to install your app and access it from the apps gallery without concern for installation details or the MATLAB path.Note
As you enter information in the Package Apps dialog box, MATLAB creates and saves a
.prj
file continuously. A .prj
file contains information about your app, such as included files and a description. Therefore, if you exit the dialog box before clicking the button, the .prj
file remains, even though a .mlappinstall
file is not created. The .prj
file enables you to quit and resume the app creation process where you left off.To create an app installation file:
- On the desktop Toolstrip, on the Home tab, click the down-arrow.
- Click .
- In the Package App dialog box, click Add main file and specify the file that you use to run the app you created.The main file must be callable with no input and must be a function or method, not a script. MATLAB analyzes the main file to determine if there are other files used in the app. For more information, see App Packaging Dependency Analysis.TipThe main file must return the figure handle of your app for MATLAB to remove your app files from the search path when users exit the app. For more information, see What Is the MATLAB Search Path?(Functions created by GUIDE return the figure handle.)
- If your app requires additional files that are not listed under Files included through analysis, add them by clicking Add files/folders.You can include external interfaces, such as MEX-files or Java® in the
.mlappinstall
file, although doing so can restrict the systems on which your app can run. - Describe your app.
- In the App Name field, type an app name.If you install the app, MATLAB uses the name for the
.mlappinstall
file and to label your app in the apps gallery. - Optionally, specify an app icon.Click the icon to the left of the App Name field to select an icon for your app or to specify a custom icon. MATLAB automatically scales the icon for use in the Install dialog box, App gallery, and quick access toolbar.
- Optionally, select a previously saved screenshot to represent your app.
- Optionally, specify author information.
- In the Description field, describe your app so others can decide if they want to install it.
- Identify the products on which your app depends.Click the plus button on the right side of the Products field, select the products on which your app depends, and then click Apply Changes. Keep in mind that your users must have all of the dependent products installed on their systems.
After you create the package, when you select a.mlappinstall
file in the Current Folder browser, MATLAB displays the information you provided (except your email address and company name) in the Current Folder browser Details panel. If you share your app in the MATLAB Central File Exchange, the same information also displays there. The screenshot you select, if any, represents your app in File Exchange. - Click .As part of the app packaging process, MATLAB creates a
.prj
file that contains information about your app, such as included files and a description. The.prj
file enables you to update the files in your app without requiring you to respecify descriptive information about the app. - In the Build dialog box, note the location of the installation file (
.mlappinstall
), and then click .
For information on installing the app, see Install Add-Ons from File.
Related Topics
Debug a MATLAB Program
To debug your MATLAB® program graphically, use the Editor/Debugger.Alternatively, you can use debugging functions in the Command Window.Both methods are interchangeable.
Before you begin debugging, make sure that your program is savedand that the program and any files it calls exist on your search pathor in the current folder.
- If you run a file with unsaved changes from withinthe Editor, then the file is automatically saved before it runs.
- If you run a file with unsaved changes from the CommandWindow, then MATLAB software runs the saved version of the file.Therefore, you do not see the results of your changes.
Set Breakpoint
Set breakpoints to pause the execution of a MATLAB fileso you can examine the value or variables where you think a problemcould be. You can set breakpoints using the Editor, using functionsin the Command Window, or both.
There are three different types of breakpoints: standard, conditional, and error. To add a standard breakpoint in the Editor, click the breakpoint alley at an executable line where you want to set the breakpoint. The breakpoint alley is the narrow column on the left side of the Editor, to the right of the line number. You also can use the F12 key to set the breakpoint.
Executable lines are indicated by a dash ( — ) in the breakpoint alley. For example, click the breakpoint alley next to line 2 in the code below to add a breakpoint at that line.
If an executable statement spans multiple lines, you can set a breakpoint at each line in that statement, even though the additional lines do not have a — (dash) in the breakpoint alley. For example, in this code. you can set a breakpoint at all four lines:
For more information on the different types of breakpoints, see Set Breakpoints.
Run File
After setting breakpoints, run the file from the Command Windowor the Editor. Running the file produces these results:
- The button changes to a button.
- The prompt in the Command Window changes to
K>>
indicatingthat MATLAB is in debug mode and that the keyboard is in control. - MATLAB pauses at the first breakpoint in theprogram. In the Editor, a green arrow just to the right of the breakpointindicates the pause. The program does not execute the line where thepause occurs until it resumes running. For example, here the debuggerpauses before the program executes
x = ones(1,10);
. - MATLAB displays the current workspace in the FunctionCall Stack, on the Editor tab in the Debug section.If you use debugging functions from the Command Window, use
dbstack
to view the Function Call Stack.
For more information on using the Function Call Stack, see Select Workspace
Pause a Running File
To pause the execution of a program while it is running, go to the Editor tab and click the button. MATLAB pauses execution at the next executable line, and the button changes to a button. To continue execution, press the button.
Pausing is useful if you want to check on the progress of along running program to ensure that it is running as expected.
Note
Clicking the pause button can cause MATLAB to pause in a file outside your own program file. Pressing the button resumes normal execution without changing the results of the file.
Find and Fix a Problem
While your code is paused, you can view or change the valuesof variables, or you can modify the code.
View or Change Variable While Debugging
View the value of a variable while debugging to see whethera line of code has produced the expected result or not. To do this,position your mouse pointer to the left of the variable. The currentvalue of the variable appears in a data tip.
The data tip stays in view until you move the pointer. If youhave trouble getting the data tip to appear, click the line containingthe variable, and then move the pointer next to the variable. Formore information, see Examine Values While Debugging.
You can change the value of a variable while debugging to seeif the new value produces expected results. With the program paused,assign a new value to the variable in the Command Window, Workspacebrowser, or Variables Editor. Then, continue running or stepping throughthe program.
For example, here MATLAB is paused inside a
for
loopwhere n = 2
:- Type
n = 7;
in the command lineto change the current value ofn
from 2 to 7. - Press Continue to run the next line of code.
MATLAB runs the code line
x(n) = 2 * x(n-1);
with n= 7
.Matlab Example Programrubackup Python
Modify Section of Code While Debugging
Matlab Example Programs
You can modify a section of code while debugging to test possiblefixes without having to save your changes. Usually, it is a good practiceto modify a MATLAB file after you quit debugging, and then savethe modification and run the file. Otherwise, you might get unexpectedresults. However, there are situations where you want to experimentduring debugging.
To modify a program while debugging:
- While your code is paused, modify a part of the filethat has not yet run.Breakpoints turn gray, indicating they are invalid.
- Select all the code after the line at which MATLAB is paused, right-click, and then select Evaluate Selection from the context menu.
After the code evaluation is complete, stop debugging and saveor undo any changes made before continuing the debugging process.
Step Through File
While debugging, you can step through a MATLAB file, pausingat points where you want to examine values.
This table describes available debugging actions and the differentmethods you can use to execute them.
Description | ToolbarButton | Function Alternative |
---|---|---|
Continue execution of file until the line where the cursoris positioned. Also available on the context menu. | Run to Cursor | None |
Execute the current line of the file. | Step | |
Execute the current line of the file and, if the lineis a call to another function, step into that function. | Step In | dbstep in |
Resume execution of file until completion or until anotherbreakpoint is encountered. | Continue | |
After stepping in, run the rest of the called functionor local function, leave the called function, and pause. | Step Out | dbstep out |
Pause debug mode. | Pause | None |
Exit debug mode. | Quit Debugging | dbquit |
End Debugging Session
After you identify a problem, end the debugging session by going to the Editor tab and clicking . You must end a debugging session if you want to change and save a file, or if you want to run other programs in MATLAB.
After you quit debugging, pause indicators in the Editor displayno longer appear, and the normal
>>
promptreappears in the Command Window in place of the K>>
.You no longer can access the call stack.Matlab Example Programrubackup Function
If MATLAB software becomes nonresponsive when it pauses at a breakpoint, press Ctrl+c to return to the MATLAB prompt.