01 Environment, Workspace & Documentation

Overview: The MATLAB Shell

MATLAB acts as both a command shell and an interpreted programming language. Efficient development relies on mastering workspace memory inspection, console suppression, and built-in help systems.


1. Cell Mode & Section Execution

In MATLAB script files (.m), code can be divided into distinct execution blocks called cells using two percent signs (` Section 1: Expensive Startup Code load myLargeData.mat y

  1. Suppression and Console print val = exp(1); % Displays ans = 2.7183 val2 = exp(2); % Suppressed (silently stored in workspace)

% 2. Formatted print function % Syntax: fprintf(formatSpec, value1, value2, …) % %d is integer, %f is float, \n is newline fprintf(‘Euler”s constant is: %f\n’, val); fprintf(‘Short display: %.2f | Long display: %.15f\n’, val, val);

% 3. Check workspace state who whos val