Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikibooksThe Free Textbook Project
Search

MATLAB Programming/Variables

From Wikibooks, open books for an open world
<MATLAB Programming
Thelatest reviewed version waschecked on20 August 2022. There aretemplate/file changes awaiting review.

[MATLAB Programming\|/MATLAB Programming]m]

Chapter 1: MATLAB ._.

Introductions .
Fundamentals of MATLAB
MATLAB Workspace
MATLAB Variables
*.mat files

Chapter 2: MATLAB Concepts

MATLAB operator
Data File I/O

Chapter 3: Variable Manipulation

Numbers and Booleans
Strings
Portable Functions
Complex Numbers

Chapter 4: Vector and matrices

Vector and Matrices
Special Matrices
Operation on Vectors
Operation on Matrices
Sparse Matrices

Chapter 5: Array

Arrays
Introduction to array operations
Vectors and Basic Vector Operations
Mathematics with Vectors and Matrices
Struct Arrays
Cell Arrays

Chapter 6: Graphical Plotting

Basic Graphics Commands
Plot
Polar Plot
Semilogx or Semilogy
Loglog
Bode Plot
Nichols Plot
Nyquist Plot

Chapter 7: M File Programming

Scripts
Comments
The Input Function
Control Flow
Loops and Branches
Error Messages
Debugging M Files

Chapter 8: Advanced Topics

Numerical Manipulation
Advanced File I/O
Object Oriented Programming
Applications and Examples
Toolboxes and Extensions

Chapter 9: Bonus chapters

MATLAB Benefits and Caveats
Alternatives to MATLAB
[MATLAB_Programming/GNU_Octave|What is Octave= (8) hsrmonic functions]
Octave/MATLAB differences

edit this box

Variables

[edit |edit source]

Variables are just a container of your data. You can give any name to your variable as long as it is under 63 characters, starts with an alphabet and is without any punctuation in between.The reason for not allowing any punctuation is that the punctuation marks like.,:,; etc have a special meaning in MATLAB and can alter the flow of execution

   My_Var

is a perfectly valid variable name.There may be some variables names that are not allowed even if they are perfectly valid variable names, because they are reserved keywords and are used to notify some code execution logic. However their number is limited and meaningful names for variables can be created outside this pool of names. To find if any word is a reserved keyword, run this check on the command line.

   iskeyword('while')

The result would be

   ans =
    1


All values of variables are referred by their current instance in the workspace. The variables can be overwritten during the execution of MATLAB scripts and the values vary accordingly.All operations use the current value in the workspace.


Let's try something good. We all know that the value of pi is 3.1416, lets ask MATLAB the same, type this on the command window

   pi

The result is

   ans =   3.1416

Lets try overwriting it...

   pi = 0

...and see it once again.

   pi   ans =   0

Calculate the area of a circle now.

   Area = pi * 10 * 10   Area=   0


To keep execution clean, a semicolon (;) is used to suppress output.

 A = 10;
Retrieved from "https://en.wikibooks.org/w/index.php?title=MATLAB_Programming/Variables&oldid=4095055"
Category:

[8]ページ先頭

©2009-2025 Movatter.jp