MATLAB Octave CLI

From NovaOrdis Knowledge Base
Revision as of 17:51, 20 December 2017 by Ovidiu (talk | contribs) (→‎short)
Jump to navigation Jump to search

Internal

Comments

% this is a comment

Prompt

PS1('>> ')

In-Line Operations

1 + 2
2 - 1
1 * 2
2 / 1
2 ^ 6 

Logical operations

Equality:

1 == 2

Non-equality:

1 ~= 2

Logical AND:

1 && 0

Logical OR:

1 || 0

Variable Assignment

<variable-name> = <variable-value>

Also see:

Variables

Printing

To print the value of the variable, simply type the name of the variable:

<variable-name>

disp

disp(<variable-name>)

Also see format.

printf

printf
fprintf
sprintf
a = pi;
sprintf('this is pi with 6 decimals %0.6f', a);

Also see:

Generic printf

format

Reset or specify the format of the output produced by disp and the normal output mechanism.

Also see:

Display

short

Fixed point format with 5 significant figures in a field that is a maximum of 10 characters wide.

long

loose

cd

Modify the current directory.

pwd

Print working directory.

clear

Delete the names matching the pattern from the symbol table. The pattern is a simplified regular expression, with '?', '*', '[...]'. With no arguments, all user-define variables (local and global) are deleted.

close

Close figure windows.

clc

Clears the terminal screen and move the cursor to the upper left corner.

fprintf

Like printf, just that the output is written to the FID stream instead of stdout.

load

Load the named variables from the file. If no variables are named, all variables found in the file will be loaded.