O'Reilly logo

Essential MATLAB for Engineers and Scientists, 6th Edition by Daniel T. Valentine, Brian Hahn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix A

Syntax: Quick Reference

In this appendix we offer examples of the MATLAB syntax most commonly used in this book.

A.1. Expressions

x = 2 ^ (2 * 3) / 4;
x = A \ b;           % solution of linear equations
a == 0 & b < 0       % a equals 0 AND b less than 0
a ~= 4 | b > 0       % a not equal to 4 OR b greater than 0

A.2. Function M-files

function y=f(x)                               % save as f.m
% comment for help

function [out1, out2] = plonk(in1, in2, in3)  % save as plonk.m
% Three input arguments, two outputs
  ...

function junk     % no input/output arguments; save as junk.m

[t, x] = ode45(@lorenz, [0 10], x0);  % function handle with @

A.3. Graphics

plot(x, y), grid     % plots vector y against vector x on a grid plot(x, y, 'b--')    % plots a blue dashed line ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required