ls Yurii.m myfilter.m~ createfigure.m rand_16_1024.mat diary rand_3.mat lecture-1.txt strassen.m my_chol.m trsm.m my_chol.m~ pwd ans = /Users/pauldj/Documents/MATLAB edit 3+6 ans = 9 3/0 ans = Inf 3/Inf ans = 0 pi ans = 3.1416 tau {??? Undefined function or variable 'tau'. } format long pi ans = 3.141592653589793 pi = 4 pi = 4 clear('pi') pi ans = 3.141592653589793 i ans = 0 + 1.000000000000000i j ans = 0 + 1.000000000000000i a {??? Undefined function or variable 'a'. } a + a {??? Undefined function or variable 'a'. } a = 3 a = 3 a+a ans = 6 a*a ans = 9 a*a; p = a*a; p p = 9 p = a*a; p = p + 1 p = 10 [ 2 ] ans = 2 [ 2, 2 ] ans = 2 2 [ 2, 4 ] ans = 2 4 [ 2; 4 ] ans = 2 4 v1 = [ 2; 4; 6 ] v1 = 2 4 6 v2 = [ 2; 4; 6 ] v2 = 2 4 6 v2 = [ 2, 4, 6 ] v2 = 2 4 6 v2 = [ 2, 4, 6 ]' v2 = 2 4 6 v2 = [ 2, 4, 6 ]'' v2 = 2 4 6 M1 = [ 2, 4, 6; 1 3 5 ] M1 = 2 4 6 1 3 5 M1 = [ 2, 4; 6 1; 3 5 ] M1 = 2 4 6 1 3 5 M1 = [ 2, 4; 6 1 0; 3 5 ] {??? Error using ==> vertcat CAT arguments dimensions are not consistent. } M1 M1 = 2 4 6 1 3 5 v1 v1 = 2 4 6 v2 v2 = 2 4 6 v2(1) ans = 2 v2(0) {??? Attempted to access v2(0); index must be a positive integer or logical. } v2(3) ans = 6 v2(4) {??? Attempted to access v2(4); index out of bounds because numel(v2)=3. } v1 v1 = 2 4 6 v1(1) ans = 2 v1(2) ans = 4 v1(3) ans = 6 v1(-1) {??? Attempted to access v1(-1); index must be a positive integer or logical. } M1 M1 = 2 4 6 1 3 5 M1(3,1) ans = 3 M1(3,1:2) ans = 3 5 1:2 ans = 1 2 1:10 ans = 1 2 3 4 5 6 7 8 9 10 1:10:2 ans = 1 1:2:10 ans = 1 3 5 7 9 10:-2:1 ans = 10 8 6 4 2 M = reshape(1:20, 4,5) M = 1 5 9 13 17 2 6 10 14 18 3 7 11 15 19 4 8 12 16 20 M( 1:3, 2:3 ) ans = 5 9 6 10 7 11 M( 2, : ) ans = 2 6 10 14 18 M( :, 3 ) ans = 9 10 11 12 M M = 1 5 9 13 17 2 6 10 14 18 3 7 11 15 19 4 8 12 16 20 M( 1:2, 1:3 ) ans = 1 5 9 2 6 10 M( 1:1, 1:3 ) ans = 1 5 9 M( 1:0, 1:3 ) ans = Empty matrix: 0-by-3 B = rand(4,4) B = Columns 1 through 3 0.814723686393179 0.632359246225410 0.957506835434298 0.905791937075619 0.097540404999410 0.964888535199277 0.126986816293506 0.278498218867048 0.157613081677548 0.913375856139019 0.546881519204984 0.970592781760616 Column 4 0.957166948242946 0.485375648722841 0.800280468888800 0.141886338627215 M( 1:0, 1:3 ) * rand( 3, 4) ans = Empty matrix: 0-by-4 1:0 ans = Empty matrix: 1-by-0 v1( 1:0 ) ans = Empty matrix: 0-by-1 M( 1:0, 1:0 ) ans = [] A = [ 1 2; 1 2] A = 1 2 1 2 B = [ A A A ] B = 1 2 1 2 1 2 1 2 1 2 1 2 B = [ A A A ]' B = 1 1 2 2 1 1 2 2 1 1 2 2 B = [ A; A; A ] B = 1 2 1 2 1 2 1 2 1 2 1 2 B = [ A A A; 3 4 4 5 5 6 ] B = 1 2 1 2 1 2 1 2 1 2 1 2 3 4 4 5 5 6 B = [ A A A; 3 4 4 5 5 6; A A' [9 9; 9 9] ] B = 1 2 1 2 1 2 1 2 1 2 1 2 3 4 4 5 5 6 1 2 1 1 9 9 1 2 2 2 9 9 B = [ A A ; 3 4; A [9 9; 9 9] ] {??? Error using ==> vertcat CAT arguments dimensions are not consistent. } B = [ A A ; 3 4 5 6; A [9 9; 9 9] ] B = 1 2 1 2 1 2 1 2 3 4 5 6 1 2 9 9 1 2 9 9 B( 1, 1) ans = 1 B(1, 1) = -1 B = -1 2 1 2 1 2 1 2 3 4 5 6 1 2 9 9 1 2 9 9 B(5, 5) = -1 B = -1 2 1 2 0 1 2 1 2 0 3 4 5 6 0 1 2 9 9 0 1 2 9 9 -1 B = zeros( 4, 4) B = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 B(5, 5) = -1 B = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 B(10, 10) = -1 B = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 A = B(1:4, 1:4) A = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 zeros(4,5) ans = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 zeros(4,4) ans = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 zeros(4) ans = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 zeros(4,1) ans = 0 0 0 0 zeros(1,4) ans = 0 0 0 0 ones(1,4) ans = 1 1 1 1 ones(4) ans = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ones(2,3,4) ans(:,:,1) = 1 1 1 1 1 1 ans(:,:,2) = 1 1 1 1 1 1 ans(:,:,3) = 1 1 1 1 1 1 ans(:,:,4) = 1 1 1 1 1 1 help HELP topics: Documents/MATLAB - (No table of contents file) matlab/general - General purpose commands. matlab/ops - Operators and special characters. matlab/lang - Programming language constructs. matlab/elmat - Elementary matrices and matrix manipulation. matlab/randfun - Random matrices and random streams. matlab/elfun - Elementary math functions. matlab/specfun - Specialized math functions. matlab/matfun - Matrix functions - numerical linear algebra. matlab/datafun - Data analysis and Fourier transforms. matlab/polyfun - Interpolation and polynomials. matlab/funfun - Function functions and ODE solvers. matlab/sparfun - Sparse matrices. matlab/scribe - Annotation and Plot Editing. matlab/graph2d - Two dimensional graphs. matlab/graph3d - Three dimensional graphs. matlab/specgraph - Specialized graphs. matlab/graphics - Handle Graphics. matlab/uitools - Graphical User Interface Tools. matlab/strfun - Character strings. matlab/imagesci - Image and scientific data input/output. matlab/iofun - File input and output. matlab/audiovideo - Audio and Video support. matlab/timefun - Time and dates. matlab/datatypes - Data types and structures. matlab/verctrl - Version control. matlab/codetools - Commands for creating and debugging code. matlab/helptools - Help commands. matlab/demos - Examples and demonstrations. matlab/timeseries - Time series data visualization and exploration. matlab/hds - (No table of contents file) matlab/guide - Graphical User Interface Tools. matlab/plottools - Graphical User Interface Tools. toolbox/local - General preferences and configuration information. shared/controllib - Control Library shared/dastudio - (No table of contents file) matlab/datamanager - (No table of contents file) simulink/simulink - Simulink simulink/blocks - Simulink block library. simulink/components - Simulink components. simulink/fixedandfloat - Simulink Fixed Point utilities. fixedandfloat/fxpdemos - Simulink Fixed Point Demos fixedandfloat/obsolete - (No table of contents file) simulink/simdemos - Simulink demonstrations and examples. simdemos/aerospace - Simulink: Aerospace model demonstrations and samples. simdemos/automotive - Simulink: Automotive model demonstrations and samples. simdemos/simfeatures - Simulink: Feature demonstrations and samples. simdemos/simgeneral - Simulink: General model demonstrations and samples. simulink/dee - Differential Equation Editor dastudio/depviewer - (No table of contents file) stateflow/stateflow - Stateflow rtw/rtw - Real-Time Workshop shared/sigbldr - (No table of contents file) simulink/modeladvisor - (No table of contents file) simulink/MPlayIO - (No table of contents file) shared/hdlshared - (No table of contents file) rtw/accel - (No table of contents file) rtw/rtwdemos - (No table of contents file) rtwdemos/rsimdemos - (No table of contents file) asap2/asap2 - (No table of contents file) can/blocks - (No table of contents file) configuration/resource - (No table of contents file) common/tgtcommon - (No table of contents file) targets/connectivity - (No table of contents file) targets/pil - (No table of contents file) stateflow/sfdemos - Stateflow demonstrations and samples. stateflow/coder - Stateflow Coder AUTOSAR/AUTOSAR - (No table of contents file) bioinfo/bioinfo - Bioinformatics Toolbox bioinfo/biolearning - Bioinformatics Toolbox -- Statistical Learning functions. bioinfo/microarray - Bioinformatics Toolbox -- Microarray support functions. bioinfo/mass_spec - Bioinformatics Toolbox -- Mass spectrometry data analysis functions. bioinfo/proteins - Bioinformatics Toolbox -- Protein analysis tools. bioinfo/biomatrices - Bioinformatics Toolbox -- Sequence similarity scoring matrices. bioinfo/biodemos - Bioinformatics Toolbox -- Tutorials, demos and examples. bioinfo/graphtheory - Bioinformatics Toolbox -- Graph Theory functions. comm/comm - Communications Toolbox comm/commdemos - Communications Toolbox Demos. commdemos/commdocdemos - Communications Toolbox Documentation Examples. comm/commobsolete - Archived MATLAB Files from Communications Toolbox Version 1.5. commblks/commblks - Communications Blockset commblks/commmasks - Communications Blockset library block mask helper functions. commblks/commmex - Communications Blockset S-function MEX-files. commblks/commblksdemos - Communications Blockset Demos. commblksobsolete/v3 - (No table of contents file) commblksobsolete/v2p5 - (No table of contents file) commblksobsolete/v2 - (No table of contents file) toolbox/compiler - MATLAB Compiler control/control - Control System Toolbox control/ctrlguis - Control System Toolbox -- Visualization and plot manipulation. control/ctrlobsolete - Control System Toolbox -- obsolete commands. control/ctrlutil - Control System Toolbox -- Utilities and MEX files. control/ctrldemos - Control System Toolbox -- Demos. shared/slcontrollib - Simulink Control Design Library curvefit/curvefit - Curve Fitting Toolbox curvefit/cftoolgui - (No table of contents file) shared/optimlib - Optimization Toolbox Library data_manager/data_manager - (No table of contents file) database/database - Database Toolbox database/dbdemos - Database Toolbox Demonstration Functions. database/vqb - Visual Query Builder functions. des/desblks - SimEvents des/desmasks - (No table of contents file) des/desmex - (No table of contents file) des/desdemos - SimEvents Demos. toolbox/distcomp - Parallel Computing Toolbox distcomp/user - (No table of contents file) distcomp/mpi - (No table of contents file) distcomp/pctdemos - (No table of contents file) distcomp/parallel - Parallel Algorithms parallel/datafun - (No table of contents file) parallel/datatypes - (No table of contents file) parallel/elfun - (No table of contents file) parallel/elmat - (No table of contents file) parallel/lapack - (No table of contents file) parallel/matfun - (No table of contents file) parallel/ops - (No table of contents file) parallel/sparfun - (No table of contents file) parallel/specfun - (No table of contents file) parallel/util - (No table of contents file) distcomp/lang - Parallel computing programming language constructs. drive/drive - SimDriveline drive/drivedemos - (No table of contents file) dspblks/dspblks - Signal Processing Blockset dspblks/dspmasks - Signal Processing Blockset mask helper functions. dspblks/dspmex - DSP Blockset S-Function MEX-files. dspblks/dspdemos - Signal Processing Blockset demonstrations and examples. shared/filterdesignlib - (No table of contents file) targets/ecoder - Real-Time Workshop Embedded Coder ecoder/ecoderdemos - (No table of contents file) mpt/mpt - Module Packaging Features mpt/user_specific - (No table of contents file) eml/eml - (No table of contents file) emlcoder/emlcoder - Embedded MATLAB Coder. filterdesign/filterdesign - Filter Design Toolbox filterdesign/quantization - (No table of contents file) filterdesign/filtdesdemos - (No table of contents file) fixedpoint/fixedpoint - Fixed-Point Toolbox fixedpoint/fidemos - (No table of contents file) fixedpoint/fixedpointtool - (No table of contents file) toolbox/fixpoint - Simulink Fixed Point fuzzy/fuzzy - Fuzzy Logic Toolbox fuzzy/fuzdemos - Fuzzy Logic Toolbox Demos. gads/gads - Genetic Algorithm and Direct Search Toolbox gads/gadsdemos - Genetic Algorithm and Direct Search Toolbox Demos ident/ident - System Identification Toolbox ident/nlident - Nonlinear System Identification features. Type "help ident" for more info. ident/idobsolete - (No table of contents file) ident/idguis - (No table of contents file) ident/idutils - (No table of contents file) ident/iddemos - (No table of contents file) iddemos/examples - (No table of contents file) images/colorspaces - Image Processing Toolbox --- colorspaces images/images - Image Processing Toolbox images/imdemos - Image Processing Toolbox --- demos and sample images images/imuitools - Image Processing Toolbox --- imuitools images/iptformats - Image Processing Toolbox --- File Formats images/iptutils - Image Processing Toolbox --- utilities shared/imageslib - Image Processing Toolbox Library shared/spcuilib - (No table of contents file) instrument/instrument - Instrument Control Toolbox instrument/instrumentdemos - (No table of contents file) instrumentblks/instrumentblks - (No table of contents file) instrumentblks/instrumentmex - (No table of contents file) instrumentblks/instrumentmasks - (No table of contents file) shared/testmeaslib - (No table of contents file) map/map - Mapping Toolbox map/mapdemos - Mapping Toolbox Demos and Sample Data Sets. map/mapdisp - (No table of contents file) map/mapformats - (No table of contents file) map/mapproj - (No table of contents file) shared/mapgeodesy - Geometric Geodesy Functions map/maputils - (No table of contents file) mech/mech - SimMechanics mech/mechdemos - SimMechanics Demos. mech/importer - (No table of contents file) slvnv/simcoverage - Simulink Model Coverage Tool mpc/mpc - Model Predictive Control Toolbox mpc/mpcdemos - (No table of contents file) mpc/mpcguis - (No table of contents file) mpc/mpcobsolete - Contents of the previous (obsolete) version of MPC Toolbox mpc/mpcutils - (No table of contents file) network_engine/network_engine - (No table of contents file) network_engine/ne_sli - (No table of contents file) toolbox/nnet - Neural Network Toolbox nnet/nncontrol - Neural Network Toolbox Control System Functions. nnet/nndemos - Neural Network Demonstrations. nnet/nnet - (No table of contents file) nnet/nnanalyze - (No table of contents file) nnet/nncustom - (No table of contents file) nnet/nndistance - (No table of contents file) nnet/nnformat - (No table of contents file) nnet/nninit - (No table of contents file) nnet/nnlearn - (No table of contents file) nnet/nnnetinput - (No table of contents file) nnet/nnnetwork - (No table of contents file) nnet/nnperformance - (No table of contents file) nnet/nnplot - (No table of contents file) nnet/nnprocess - (No table of contents file) nnet/nnsearch - (No table of contents file) nnet/nntopology - (No table of contents file) nnet/nntrain - (No table of contents file) nnet/nntransfer - (No table of contents file) nnet/nnweight - (No table of contents file) nnguis/nftool - (No table of contents file) nnguis/nntool - (No table of contents file) nnet/nnobsolete - Neural Network Toolbox nnet/nnutils - Neural Network Toolbox nnguis/nnguiutils - (No table of contents file) nndemos/nndatasets - (No table of contents file) nnguis/nntraintool - (No table of contents file) optim/optim - Optimization Toolbox optim/optimdemos - Demonstrations of large-scale methods. toolbox/pde - Partial Differential Equation Toolbox pm_sli/pm_sli - (No table of contents file) pm_util/pm_util - (No table of contents file) slvnv/reqmgt - Requirements Management Interface. slvnv/rmidemos - (No table of contents file) rf/rf - RF Toolbox rf/rfdemos - RF Toolbox Demos. rf/rftool - RF Tool (GUI) rfblks/rfblks - RF Blockset rfblks/rfblksmasks - RF Blockset mask helper functions. rfblks/rfblksmex - RF Blockset S-functions. rfblks/rfblksdemos - RF Blockset Demos. robust/robust - Robust Control Toolbox robust/rctlmi - Robust Control Toolbox - LMI Solvers. robust/rctutil - (No table of contents file) robust/rctdemos - (No table of contents file) rctobsolete/lmi - (No table of contents file) mutools/commands - (No table of contents file) mutools/subs - Utilities for obsolete MUTOOLS commands. signal/signal - Signal Processing Toolbox signal/sigtools - (No table of contents file) signal/sptoolgui - (No table of contents file) signal/sigdemos - (No table of contents file) simscape/simscape - Simscape slcontrol/slcontrol - Simulink Control Design slcontrol/slctrlguis - (No table of contents file) slcontrol/slctrlutil - (No table of contents file) slcontrol/slctrldemos - (No table of contents file) shared/sldv - (No table of contents file) sloptim/sloptim - Simulink Response Optimization sloptim/sloptguis - (No table of contents file) sloptim/sloptdemos - Simulink Response Optimization Demos. sloptim/sloptobsolete - (No table of contents file) slvnv/slvnv - Simulink Verification and Validation slvnv/simcovdemos - (No table of contents file) toolbox/splines - Spline Toolbox toolbox/stats - Statistics Toolbox shared/statslib - Statistics Toolbox Library toolbox/symbolic - Symbolic Math Toolbox vipblks/vipblks - Video and Image Processing Blockset vipblks/vipmasks - (No table of contents file) vipblks/vipmex - (No table of contents file) vipblks/vipdemos - Video and Image Processing Blockset demonstrations and examples. vr/vr - Virtual Reality Toolbox vr/vrdemos - Virtual Reality Toolbox examples. wavelet/wavelet - Wavelet Toolbox wavelet/wmultisig1d - (No table of contents file) wavelet/wavedemo - (No table of contents file) wavelet/compression - (No table of contents file) doc help ones ONES Ones array. ONES(N) is an N-by-N matrix of ones. ONES(M,N) or ONES([M,N]) is an M-by-N matrix of ones. ONES(M,N,P,...) or ONES([M N P ...]) is an M-by-N-by-P-by-... array of ones. ONES(SIZE(A)) is the same size as A and all ones. ONES with no arguments is the scalar 1. ONES(M,N,...,CLASSNAME) or ONES([M,N,...],CLASSNAME) is an M-by-N-by-... array of ones of class CLASSNAME. Note: The size inputs M, N, and P... should be nonnegative integers. Negative integers are treated as 0. Example: x = ones(2,3,'int8'); See also eye, zeros. Overloaded methods: distribution1d/ones codistributor1d/ones Reference page in Help browser doc ones rand( 4 ) ans = Columns 1 through 3 0.655477890177557 0.276922984960890 0.694828622975817 0.171186687811562 0.046171390631154 0.317099480060861 0.706046088019609 0.097131781235848 0.950222048838355 0.031832846377421 0.823457828327293 0.034446080502909 Column 4 0.438744359656398 0.381558457093008 0.765516788149002 0.795199901137063 M = rand( 4 ) M = Columns 1 through 3 0.186872604554379 0.709364830858073 0.655098003973841 0.489764395788231 0.754686681982361 0.162611735194631 0.445586200710899 0.276025076998578 0.118997681558377 0.646313010111265 0.679702676853675 0.498364051982143 Column 4 0.959743958516081 0.340385726666133 0.585267750979777 0.223811939491137 diag( M ) ans = 0.186872604554379 0.754686681982361 0.118997681558377 0.223811939491137 diag( [1 3 4 5] ) ans = 1 0 0 0 0 3 0 0 0 0 4 0 0 0 0 5 reshape( 1:20, 4, 5) ans = 1 5 9 13 17 2 6 10 14 18 3 7 11 15 19 4 8 12 16 20 reshape( 1:20, 2, 5, 2) ans(:,:,1) = 1 3 5 7 9 2 4 6 8 10 ans(:,:,2) = 11 13 15 17 19 12 14 16 18 20 M reshape( 1:20, 4, 5) {??? Error: "M" was previously used as a variable, conflicting with its use here as the name of a function or command. See MATLAB Programming, "How MATLAB Recognizes Function Calls That Use Command Syntax" for details. } M = reshape( 1:20, 4, 5) M = 1 5 9 13 17 2 6 10 14 18 3 7 11 15 19 4 8 12 16 20 diag(M) ans = 1 6 11 16 M = reshape( 1:20, 2, 4, 5) {??? Error using ==> reshape To RESHAPE the number of elements must not change. } M = reshape( 1:20, 2, 5, 2) M(:,:,1) = 1 3 5 7 9 2 4 6 8 10 M(:,:,2) = 11 13 15 17 19 12 14 16 18 20 diag(M) {??? Error using ==> diag First input must be 2D. } M = reshape( 1:16, 4, 4) M = 1 5 9 13 2 6 10 14 3 7 11 15 4 8 12 16 diag(diag(M)) ans = 1 0 0 0 0 6 0 0 0 0 11 0 0 0 0 16 eye(4) ans = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 M .* eye(4) ans = 1 0 0 0 0 6 0 0 0 0 11 0 0 0 0 16 [ , , , ; ; ; ] ??? [ , , , ; ; ; ] | {Error: Expression or statement is incorrect--possibly unbalanced (, {, or [. } rand, eye, ones, zeros, randn ans = 0.751267059305653 ans = 1 ans = 1 ans = 0 ans = -1.089064295052236 M( ) = ??? M( ) = | {Error: Expression or statement is incomplete or incorrect. } M M = 1 5 9 13 2 6 10 14 3 7 11 15 4 8 12 16 M( 4:-1:3, 4:-2:1 ) ans = 16 8 15 7 v1 v1 = 2 4 6 v1( : ) ans = 2 4 6 v2 v2 = 2 4 6 v2( : ) ans = 2 4 6 M M = 1 5 9 13 2 6 10 14 3 7 11 15 4 8 12 16 M( : ) ans = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 : ??? : | {Error: Unexpected MATLAB operator. } ' ??? ' | {Error: A MATLAB string constant is not terminated properly. } [ 1 2 3 ]( 3 ) ??? [ 1 2 3 ]( 3 ) | {Error: Unbalanced or unexpected parenthesis or bracket. } v2 = [ 1 2 3 ]; v2( 3 ) ans = 3 M M = 1 5 9 13 2 6 10 14 3 7 11 15 4 8 12 16 M( 1: end, end:-1:1 ) ans = 13 9 5 1 14 10 6 2 15 11 7 3 16 12 8 4 M( 1:, end:-1:1 ) ??? M( 1:, end:-1:1 ) | {Error: Expression or statement is incorrect--possibly unbalanced (, {, or [. } M( :, end:-1:1 ) ans = 13 9 5 1 14 10 6 2 15 11 7 3 16 12 8 4 M M = 1 5 9 13 2 6 10 14 3 7 11 15 4 8 12 16 M( 1:3 ) ans = 1 2 3 M( 1:3, 3 ) = [ 5 6 7 ] M = 1 5 5 13 2 6 6 14 3 7 7 15 4 8 12 16 M( 1:3, 3 ) = [ 10 11 12 ]' M = 1 5 10 13 2 6 11 14 3 7 12 15 4 8 12 16 M( 2:3, 3:-1:2 ) = [ 10 11; 12 13 ] M = 1 5 10 13 2 11 10 14 3 13 12 15 4 8 12 16 M( 2:3, [3 2] ) = [ 10 11; 12 13 ] M = 1 5 10 13 2 11 10 14 3 13 12 15 4 8 12 16 M( [2 3], [3 2] ) = [ 10 11; 12 13 ] M = 1 5 10 13 2 11 10 14 3 13 12 15 4 8 12 16 M M = 1 5 10 13 2 11 10 14 3 13 12 15 4 8 12 16 M( 2, [3 4 3 4 3 4 3 4]) ans = 10 14 10 14 10 14 10 14 M M = 1 5 10 13 2 11 10 14 3 13 12 15 4 8 12 16 M( 2, [1:0:2] ) ans = Empty matrix: 1-by-0 M( 2, [ ] ) ans = Empty matrix: 1-by-0 M M = 1 5 10 13 2 11 10 14 3 13 12 15 4 8 12 16 find( M > 10 ) ans = 6 7 11 12 13 14 15 16 M > 10 ans = 0 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 whos('M') Name Size Bytes Class Attributes M 4x4 128 double B = M > 10 B = 0 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 whos('B') Name Size Bytes Class Attributes B 4x4 16 logical B(2,2) + pi ans = 4.141592653589793 rand ans = 0.505957051665142 floor(rand * 2) ans = 1 floor(rand * 2) ans = 1 floor(rand * 2) ans = 1 floor(rand * 2) ans = 1 floor(rand * 2) ans = 0 floor(rand * 2) ans = 0 floor(rand * 2) ans = 0 floor(rand(4) * 2) ans = 1 1 1 1 0 0 0 1 1 0 0 1 0 0 1 0 B = floor(rand(4) * 2) B = 1 0 1 0 1 0 0 0 0 1 1 0 1 1 0 1 whos('B') Name Size Bytes Class Attributes B 4x4 128 double whos('B') Name Size Bytes Class Attributes B 4x4 128 double B = M > 10 B = 0 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 whos('B') Name Size Bytes Class Attributes B 4x4 16 logical B(1,2) = .5 B = 0 1 0 1 0 1 0 1 0 1 1 1 0 0 1 1 whos('B') Name Size Bytes Class Attributes B 4x4 16 logical B(1,2) = 2 B = 0 1 0 1 0 1 0 1 0 1 1 1 0 0 1 1 whos('B') Name Size Bytes Class Attributes B 4x4 16 logical B(1,2) = 0 B = 0 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 whos('B') Name Size Bytes Class Attributes B 4x4 16 logical B * -1 ans = 0 0 0 -1 0 -1 0 -1 0 -1 -1 -1 0 0 -1 -1 whos('B') Name Size Bytes Class Attributes B 4x4 16 logical B * -2 ans = 0 0 0 -2 0 -2 0 -2 0 -2 -2 -2 0 0 -2 -2 whos('B') Name Size Bytes Class Attributes B 4x4 16 logical B = B * -1 B = 0 0 0 -1 0 -1 0 -1 0 -1 -1 -1 0 0 -1 -1 whos('B') Name Size Bytes Class Attributes B 4x4 128 double if( 3 ) c=4 else c=5 end ??? if( 3 ) c=4 else c=5 end | {Error: Illegal use of reserved keyword "else". } if( 3 ) c=4; else c=5 end ??? if( 3 ) c=4; else c=5 end | {Error: Illegal use of reserved keyword "end". } if( 3 ) c=4; else c=5; end c c = 4 if( -3 ) c=4; else c=5; end c c = 4 if( 0 ) c=4; else c=5; end c c = 5 help or | Logical OR. A | B performs a logical OR of arrays A and B and returns an array containing elements set to either logical 1 (TRUE) or logical 0 (FALSE). An element of the output array is set to 1 if either input array contains a non-zero element at that same array location. Otherwise, that element is set to 0. A and B must have the same dimensions unless one is a scalar. C = OR(A,B) is called for the syntax 'A | B' when A or B is an object. Note that there are two logical OR operators in MATLAB. The | operator performs an element-by-element OR between matrices, while the || operator performs a short-circuit OR between scalar values. These operations are explained in the MATLAB Programming documentation on logical operators, under the topic of Basic Program Components. See also relop, and, xor, not Overloaded methods: distributed/or codistributed/or Reference page in Help browser doc or A = [ 1 2; 3 4]; B = [1 1; 1 -1]; [A B] ans = 1 2 1 1 3 4 1 -1 [ A*B B*A; A.*B B.*A ] ans = 3 -1 4 6 7 -1 -2 -2 1 2 1 2 3 -4 3 -4 diary off