cs221-section2

cs221-section2 - % CS221, Fall 2009-10 % Matlab Review...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
% CS221, Fall 2009-10 % Matlab Review Session % To run matlab, first login to one of the clusters (such as % myth.stanford.edu) using SecureCRT on Windows or typing from the command % line: % > ssh username@myth.stanford.edu -X % Then, to run matlab with the full display (might be slow): % % To instead run matlab with the GUI and the display turned off entirely % (no plotting, command line only), don't use -X when logging in, or run: % > matlab -nodisplay % To run matlab from the command line but still be able to display plots: % > matlab -nojvm %% Elementary operations 5+6 3-2 5*8 1/2 2^6 1 == 2 % false 1 ~= 2 % true. note, not "!=" 1 || 0 xor(1,0) %% Variable assignment a = 3; % semicolon suppresses output b = 'hi'; c = 3>=1; % Displaying them: a = pi disp(sprintf('2 decimals: %0.2f', a)) disp(sprintf('6 decimals: %0.6f', a)) fprintf('6 decimals: %0.6f\n', a) format long a format short a %% Vectors and matrices A = [1 2; 3 4; 5 6] v = [1 2 3] v = [1; 2; 3] v = 1:6 % from 1 to 6, assumes stepsize of 1 v = [1:0.1:2] % from 1 to 2, with stepsize of 0.1. Useful for plot axes C = 2*ones(2,3) % same as C = [2 2 2; 2 2 2] w = ones(1,3) % 1x3 vector of ones w = zeros(1,3) w = rand(1,3) % drawn from a uniform distribution w = randn(1,3) % drawn from a normal distribution (mean=0, var=1)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/15/2009 for the course CS 221 at Stanford.

Page1 / 5

cs221-section2 - % CS221, Fall 2009-10 % Matlab Review...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online