MATLAB Commands Last Updated : 04 Jul, 2021 Comments Improve Suggest changes Like Article Like Report MATLAB is an interactive multi-programming language and numeric computing environment developed by MathWorks. MATLAB provides the Commands that will be used when the user wants to interact with any application using the command line interface. Following are the lists of commands used in MATLAB. Commands for Managing a SessionCommand Use clcClears command windowclearRemoves the variables from memoryglobalDeclares variables globallyexistChecks for the existence of a particular file or memoryhelpSearches for a help topicquitStops MATLABwhoLists current variables in uselookforSearches help entries for a keyboard Example 1 Matlab % MATLAB Code to illustrate % global function setGlobalx(val) global x Output: x = val; Example 2 Matlab % MATLAB Code to illustrate who x = 2 who Output: Variables in the current scope: x Example 3 Matlab % MATLAB Code to illustrate % clear clear type x Output: error: type 'x' is undefinedCommands for Working with the SystemCommand UsecdChanges current directorydate Displays current datedeleteDeletes a filedirLists all the files in a directorypathDisplays search pathpwdDisplays current directorytypeDisplays content of a filewklreadReads.wk1 spreadsheet filesaveSaves workplace variables in a file Example 1 Matlab % MATLAB Code to illustrate % pwd pwd Output: ans = /home/oo Example 2 Matlab % MATLAB Code to illustrate % date c = date Output: c= '18-jun-2021'Input and Output CommandsCommand UsedispDisplays content of an array or a stringfscanfReads formatted data from a fileformatControls screen-display formatfprintfPerforms formatted writes to file or screen inputDisplays the prompt and waits for input;Suppresses screen printing Example 1 Matlab % MATLAB Code to illustrate % disp A = [15 150]; S = 'Hello World.'; disp(A) disp(S) Output: 15 150 Hello World. Example 2 Matlab % MATLAB Code to illustrate %input age = input('how old are you: '); % At this point, the variable: age, will contain % whatever value the user types Output: 20 Vector, Matrix, and Array CommandsCommand Usecat Concatenates the arrayfindFinds the indices of nonzero elementsmax Returns the largest elementminReturns the smallest elementprodProduct of each columnsortSorts each columnrankComputes rank of a matrixeyeCreates an identity matrixinv Computes the inverse of a matrix Example 1 Matlab % MATLAB Code to illustrate %cat array1 = [1,2,3] array2 = [4,5,6] cat(1,array1,array2) Output: ans = 1 2 3 4 5 6 Example 2 Matlab % MATLAB Code to illustrate %max max(array1) Output: ans = 3 Example 3 Matlab %MATLAB Code to illustrate %min min(array2) Output: ans = 4 Matlab %MATLAB Code to illustrate %eye eye(2,2) Output: ans = Diagonal Matrix 1 0 0 1 Plotting Commands: Commands UseaxisSets axis limitgridDisplays grid linesplotGenerates xy plottitle Puts title at top of the plotclose Closes current plotbarCreates bar chartprint Prints the plot / saves the plotfigureOpens a new figure windowClose allCloses all plots Example1: Matlab % MATLAB Code to illustrate %plot x = linspace(0,20) y = cos(x) plot(x,y) Output: Example 2: Matlab %MATLAB Code to illustrate %grid x = linspace(0,20) y = cos(x) plot(x,y) grid on Output: Create Quiz Comment D deepthikamath Follow 0 Improve D deepthikamath Follow 0 Improve Article Tags : Software Engineering MATLAB Explore Software Engineering BasicsIntroduction to Software Engineering7 min readSoftware Development Life Cycle (SDLC)6 min readSoftware Quality - Software Engineering5 min readISO/IEC 9126 in Software Engineering4 min readBoehm's Software Quality Model4 min readSoftware Crisis - Software Engineering3 min readSoftware Measurement & MetricesSoftware Measurement and Metrics4 min readPeople Metrics and Process Metrics in Software Engineering7 min readHalsteadâs Software Metrics - Software Engineering10 min readCyclomatic Complexity6 min readFunctional Point (FP) Analysis - Software Engineering8 min readLines of Code (LOC) in Software Engineering4 min readSoftware Development Models & Agile MethodsWaterfall Model - Software Engineering12 min readWhat is Spiral Model in Software Engineering?9 min readPrototyping Model - Software Engineering7 min readIncremental Process Model - Software Engineering6 min readRapid Application Development Model (RAD) - Software Engineering9 min readCoupling and Cohesion - Software Engineering10 min readAgile Software Development - Software Engineering15+ min readSRS & SPMSoftware Requirement Specification (SRS) Format5 min readSoftware Engineering | Quality Characteristics of a good SRS7 min readSoftware Project Management (SPM) - Software Engineering8 min readCOCOMO Model - Software Engineering15+ min readCapability Maturity Model (CMM) - Software Engineering10 min readIntegrating Risk Management in SDLC | Set 18 min readSoftware Maintenance - Software Engineering13 min readTesting & DebuggingWhat is Software Testing?11 min readTypes of Software Testing15+ min readTesting Guidelines - Software Engineering3 min readWhat is Debugging in Software Engineering?11 min readVerification & ValidationVerification and Validation in Software Engineering6 min readRole of Verification and Validation (V&V) in SDLC5 min readRequirements Validation Techniques - Software Engineering8 min readPractice QuestionsTop 50+ Software Engineering Interview Questions and Answers15+ min read Like