- Matlab Tutorial
- MATLAB - Home
- MATLAB - Overview
- MATLAB - Environment Setup
- MATLAB - Syntax
- MATLAB - Variables
- MATLAB - Commands
- MATLAB - M-Files
- MATLAB - Data Types
- MATLAB - Operators
- MATLAB - Decisions
- MATLAB - Loops
- MATLAB - Vectors
- MATLAB - Matrix
- MATLAB - Arrays
- MATLAB - Colon Notation
- MATLAB - Numbers
- MATLAB - Strings
- MATLAB - Functions
- MATLAB - Data Import
- MATLAB - Data Output
- MATLAB Advanced
- MATLAB - Plotting
- MATLAB - Graphics
- MATLAB - Algebra
- MATLAB - Calculus
- MATLAB - Differential
- MATLAB - Integration
- MATLAB - Polynomials
- MATLAB - Transforms
- MATLAB - GNU Octave
- MATLAB - Simulink
- MATLAB Useful Resources
- MATLAB - Quick Guide
- MATLAB - Useful Resources
- MATLAB - Discussion
Vectors with Uniformly Spaced Elements
MATLAB allows you to create a vector with uniformly spaced elements.
To create a vector v with the first element f, last element l, and the difference between elements is any real number n, we write −
v = [f : n : l]
Example
Create a script file with the following code −
v = [1: 2: 20]; sqv = v.^2; disp(v); disp(sqv);
When you run the file, it displays the following result −
1 3 5 7 9 11 13 15 17 19 1 9 25 49 81 121 169 225 289 361
matlab_vectors.htm
Advertisements