Jul 20, 2024
7 + 8, sqrt(225).7 + 8, variable ans holds value 15.clc: Clears the command window.clear vars: Clears workspace variables.x = 10, y = 20.x + y.; to suppress output.who and whos commands list current variables and their types.double, char, string.
w = 'new', z = "York".+, -, *, /, ^ (power).sqrt(8*9) same as x = 8*9; sqrt(x).a(2,3) gives element in 2nd row, 3rd column.end to access the last element.*x = 1:10, linspace(0, 100, 20).A = [1 3; 2 -10].A * B, A .* B (element-wise).zeros(2,3).ones(2,3).eye(3).clearvars, clc commands suggested at the start.new script button.Run button or Ctrl+Enter for quick execution.y = @(x) -((x - 3).^2) + 10;.plot(x, y), plot(x, y, 'r--') for red dashed lines.xlabel(), ylabel(), title(), legend().hold on to overlay plots.subplot(rows, columns, position) to create complex figures.figure, axes properties.>, <, ==, ~=, &&, ||.if, else, elseif, end.
if num3 >= 3, disp('wow'), end.for index = start:step:end, ... end.
for i = 1:10, disp(i), end.while condition, ... end.
while z > 2, z = z - 1, end.tic and toc to measure execution time.% for comments, %% for section titles.help, doc) and online resources to learn and troubleshoot.