Ir al contenido
Hub Nexus
Actualizado

AutorAún sin autorAsumirla

¿Ves algo que mejorar? Propón un cambio.

Apoyo

Esta página es pública.

Variables

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;

Where this page came from

This page was imported from Wikibooks. From “MATLAB Programming” on Wikibooks, by its contributors, under CC BY-SA 4.0. Changed here: set as a page; navigation and edit links left out; each image under its own licence, credited in its caption.

Nobody has written it yet — it is the source material at a new address, which is why search engines are asked to skip it and why no one earns from it. It is up for grabs: take it on, and it is yours to rewrite and to earn from.

En estas publicacionesMATLAB Programming

IdiomasEnglish

Licencia: CC BY-SA 4.0 · Adaptado de en.wikibooks.org

Puntos de vista

Comentarios

Spinner Logo
Versión: 2CC0 1.0 (dominio público)
The runaway star that left the Tarantula Nebula
Versión: 2CC0 1.0 (dominio público)
The Eagle Nebula, seen in the infrared
Versión: 2CC0 1.0 (dominio público)
The Cosmic Cliffs are not cliffs
Versión: 2CC0 1.0 (dominio público)
The recommended targets are real, but the largest health gain is between doing nothing and doing a little. That is the part worth knowing if you are starting from nothing.
Versión: 2CC0 1.0 (dominio público)
Sleep is not one state but a cycle through several, each doing different work. Most sleep disorders are a failure to complete that cycle rather than a shortage of hours.
Versión: 2CC0 1.0 (dominio público)
Four nebulae that revealed the shape of our galaxy