{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

cs221-section2

cs221-section2 - CS221 Fall 2009-10 Matlab Review Session...

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

% 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 [email protected] -X % Then, to run matlab with the full display (might be slow): % > matlab & % 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 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)

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 5

cs221-section2 - CS221 Fall 2009-10 Matlab Review Session...

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

View Full Document
Ask a homework question - tutors are online