Tagged: Examples

Working with Matrices in Matlab

Generating Matrices MATLAB software provides four functions that generate basic matrices. zeros All zeros ones All ones rand Uniformly distributed random elements randn Normally distributed random elements Here are some examples: Z = zeros(2,4)...

Matlab Expressions

Matlab Expressions Variables Like most other programming languages, the MATLAB language provides mathematical expressions, but unlike most programming languages, these expressions involve entire matrices. MATLAB does not require any type declarations or dimension statements....

for

for Repeat statements a specific number of times. The general form of a for statement is: for variable = expr, statement, …, statement END The columns of the expression are stored one at a...

end

end Terminate scope of FOR, WHILE, SWITCH, TRY, and IF statements. Without END’s, FOR, WHILE, SWITCH, TRY, and IF wait for further input. Each end is paired with the closest previous unpaired FOR, WHILE,...

Examples of Expressions

You have already seen several examples of MATLAB expressions. Here are a few more examples, and the resulting values. rho = (1+sqrt(5))/2 rho = 1.6180 a = abs(3+4i) a = 5 z = sqrt(besselk(4/3,rho-i))...

matlab

open

Matlab open command OPEN Open files by extension. open NAME where NAME must contain a string, does different things depending on the type of the object named by that string: Type Action —- ——...

addpath

addpath Add directory to search path. addpath DIRNAME prepends the specified directory to the current matlabpath. Surround the DIRNAME in quotes if the name contains a space. addpath DIR1 DIR2 DIR3 … prepends all...