Tagged: High-Level Vs Low-Level Code

Matlab Tips and Tricks 0

Matlab Tips and Tricks

Introduction

Like other computer languages, M AT L A B provides operators and functions for creating and mani-
pulating arrays. Arrays may be manipulated one element at a time, like one does in low-level lan-
guages. Since M AT L A B is a high-level programming language it also provides high-level operators
and functions for manipulating arrays.
Any task which can be done in M AT L A B with high-level constructs may also be done with low-
level constructs. Here is an example of a low-level way of squaring the elements of a vector
x = [ 1 2 3 4 5 ]; % vector of values to square
y = zeros(size(x)); % initialize new vector
for i = 1 : numel(x) % for each index
y(i) = x(i)^2; % square the value