MATLAB Tutorial CSHA Suzhou Course 2011
|
|
- Allen Simmons
- 5 years ago
- Views:
Transcription
1 MATLAB Tutorial CSHA Suzhou Course 2011 Basics Malte J. Rasch National Key Laboratory of Cognitive Neuroscience and Learning Beijing Normal University China July 15, 2011
2 Overview Simply introduction to basic algebra and matrix indexing Simply introduction to plotting and programming with MATLAB Exercises
3 Why MATLAB?
4 Why MATLAB? MathWorks Homepage: Over one million people around the world use MATLAB for technical computing. [...] By combining a powerful numeric engine and technical programming environment with interactive exploration and visualization tools, MATLAB has become the language of technical computing. [...]
5 Why MATLAB? MathWorks Homepage: Over one million people around the world use MATLAB for technical computing. [...] By combining a powerful numeric engine and technical programming environment with interactive exploration and visualization tools, MATLAB has become the language of technical computing. [...] Of course, this is an advertisement...
6 Why MATLAB? Pro: Matrix-like numerical operations very fast and easy to use Good plotting capabilities Script language for programming small to medium sized problems in applied mathematics (rapid prototyping) Widely used in the neuroscience community for data analysis as well as computational projects
7 Why MATLAB? Pro: Matrix-like numerical operations very fast and easy to use Good plotting capabilities Script language for programming small to medium sized problems in applied mathematics (rapid prototyping) Widely used in the neuroscience community for data analysis as well as computational projects Contra: Support of symbolic/analytic expressions less advanced Mathematica, Maple Often not flexible/ fast enough for big projects e.g. Python much more versatile specialized software for detailed/large neural network simulations (NEURON, PCSIM, NEST, GENESIS,...) Very expensive, especially when using on a cluster free alternative: (scientific) python
8 Starting MATLAB Easy: Just click on MATLAB symbol...
9 Scalar expressions Binary operations: work as expected, use = + - * / ^. Example (compute y = a2 x 2+a + b) >> a = 2; >> b = 1; >> x = 0.5; >> y = a^2*x/(2+a) + b; >> y y = Unary operations: called as functions with (), eg. sin cos tan atan sqrt log gamma Example ( compute y = sin x ln x ) >> x = 0.5; >> y = sqrt(sin(x))/log(x);
10 Getting help Each MATLAB function has a header which describes its usage Just type: >> help command or >> doc command Alternatively:
11 MATLAB == MATrix LABoratory Not suprisingly, in MATLAB everything is about matrices.
12 MATLAB == MATrix LABoratory Not suprisingly, in MATLAB everything is about matrices. However, the matrix-like data structure in MATLAB is better called a n-dimensional array, because it can be manipulated in non-algebraic ways.
13 MATLAB == MATrix LABoratory Not suprisingly, in MATLAB everything is about matrices. However, the matrix-like data structure in MATLAB is better called a n-dimensional array, because it can be manipulated in non-algebraic ways. (Almost) all functions will work on arrays as well usually element-wise Many MATLAB functions will produce arrays as output Array operations much faster than for-looped element-wise operation
14 Arrays: Overview How to initialize arrays Indexing Calculating with arrays Array manipulation
15 Syntax for initializing arrays 1 Implicitly, using function returning an array
16 Syntax for initializing arrays 1 Implicitly, using function returning an array 2 By explicit concatenation Concatenation of columns of arrays [ arr1, arr2,..., arrn] Concatenation of rows of arrays [ arr1; arr2;... ; arrn]
17 Syntax for initializing arrays 1 Implicitly, using function returning an array 2 By explicit concatenation Concatenation of columns of arrays [ arr1, arr2,..., arrn] Concatenation of rows of arrays [ arr1; arr2;... ; arrn] Note: an scalar is also regarded as an array (of size [1,1]). Note 2: arrays must have matching sizes.
18 Syntax for initializing arrays 1 Implicitly, using function returning an array 2 By explicit concatenation Concatenation of columns of arrays [ arr1, arr2,..., arrn] Concatenation of rows of arrays [ arr1; arr2;... ; arrn] Note: an scalar is also regarded as an array (of size [1,1]). Note 2: arrays must have matching sizes. Example (Concatenation) >> A = [1,2;3,4] A = >> B = [A,A] B = >> C = [A;A] C =
19 Syntax for initializing arrays: implicitly Functions that pre-allocate memory and set each array element to an initial value: zeros all zero ND-arrays ones all one ND-arrays rand random ND-arrays (equally in [0, 1])
20 Syntax for initializing arrays: implicitly Functions that pre-allocate memory and set each array element to an initial value: zeros all zero ND-arrays ones all one ND-arrays rand random ND-arrays (equally in [0, 1]) colon (:) for linear sequences, syntax: istart:[step:]iend
21 Syntax for initializing arrays: implicitly Functions that pre-allocate memory and set each array element to an initial value: zeros all zero ND-arrays ones all one ND-arrays rand random ND-arrays (equally in [0, 1]) colon (:) for linear sequences, syntax: istart:[step:]iend many others, for details type: help command randn, linspace, logspace, ndgrid, repmat,...
22 Syntax for initializing arrays: implicitly Functions that pre-allocate memory and set each array element to an initial value: zeros all zero ND-arrays ones all one ND-arrays rand random ND-arrays (equally in [0, 1]) colon (:) for linear sequences, syntax: istart:[step:]iend many others, for details type: help command randn, linspace, logspace, ndgrid, repmat,... Example (Functions initializing arrays) >> A = zeros(3,3); >> A = ones(4,4,4); >> size(a) ans = >> x = 3:-0.5:1 x = >> A = ones(2)
23 Indexing arrays 1 Subscript of a matrix: access the (i,j)-th element of a 2D-matrix W of dimension (m,n) >> W(i,j) = 1 Note: The first index is always 1 (not 0 as in most other languages)
24 Indexing arrays 1 Subscript of a matrix: access the (i,j)-th element of a 2D-matrix W of dimension (m,n) >> W(i,j) = 1 Note: The first index is always 1 (not 0 as in most other languages) 2 Linear index of a matrix: access the (i,j)th element of the 2D-matrix W of dimension (m,n) >> linearidx = i + (j-1)*m; >> W(linearidx)
25 Indexing arrays 1 Subscript of a matrix: access the (i,j)-th element of a 2D-matrix W of dimension (m,n) >> W(i,j) = 1 Note: The first index is always 1 (not 0 as in most other languages) 2 Linear index of a matrix: access the (i,j)th element of the 2D-matrix W of dimension (m,n) >> linearidx = i + (j-1)*m; >> W(linearidx) 3 Slice indexing with : access the i-th row and jth column in W, respectively >> wi = W(i,:) >> wj = W(:,j) get all elements as a concatenated column vector >> W(:)
26 Indexing arrays (2) 4 Multiple indices vectors of linear indices can be used >> W([1, 4, 5,6]) access the 1st to 4th rows of the 2D-matrix W of dimension (m,n) >> W(1:4,:) access the 2nd (m,n)-slice of a 3D-matrix V of dimension (m,n,p) >> W(:,:,2)
27 Indexing arrays (2) 4 Multiple indices vectors of linear indices can be used >> W([1, 4, 5,6]) access the 1st to 4th rows of the 2D-matrix W of dimension (m,n) >> W(1:4,:) access the 2nd (m,n)-slice of a 3D-matrix V of dimension (m,n,p) >> W(:,:,2) 5 Logical indexing logical matrices of the same size as W can be used as index (very useful) >> W(W>0) >> W(find(W>0)) = 1
28 Calculating with arrays 1 Element-wise interpretation For instance, sin cos log etc. Reserved symbols,.*./.^ 2 true matrix interpretation (with dot product) Symbols * / ^ etc. 3 Operations on one specified dimensions of the matrix For instance, sum mean max etc. 4 Array manipulations eg. reshape repmat permute circshift tril Example (element-wise product and dot product) >> A = ones(2,2); >> A.*A ans = >> A*A ans =
29 Array manipulation Usage of array manipulation is important to achieve fast codes. circshift shifts array circular reshape reshapes arrays to new size permute permutes dimensions of array repmat repeats and concattenates arrays and many more, eg. shiftdim, squeeze
30 Array manipulation Usage of array manipulation is important to achieve fast codes. circshift shifts array circular reshape reshapes arrays to new size permute permutes dimensions of array repmat repeats and concattenates arrays Example (reshape) and many more, eg. shiftdim, squeeze >> r = rand(10,10); >> r = reshape(r,[50,2]); >> size(r) ans = 50 2
31 Calculating with arrays is straightforward however, carefully check the size of matrices if element-wise or matrix-like operations are intended which matrix dimension to operate on
32 Calculating with arrays is straightforward however, carefully check the size of matrices if element-wise or matrix-like operations are intended which matrix dimension to operate on Example (compute y i = Wx i + b with b,x i R 2 ) >> W = [1,0.2;0.4,1]; >> b = [1;2] + 0.1; >> x = 2*randn(2,1); >> y = W * x + b y = >> N = 5; % same as b = [b,b,b,b,b] >> bi = repmat(b,[1,n]); >> xi = 2*randn(2,N); >> xi(:,1) = x; >> yi = W * xi + bi yi = [..] [..]
33 Useful operations on specified dimensions Often used functions on array elements include size number of elements in a dimension sum sum of elements along an array dimension prod product of elements all, any logical AND or OR, respectively mean mean of elements max maximal element of an array dimension and many more, eg. min var std median diff Functions are usually called as res = func(arr,dim); Note: Some functions have the syntax res = func(arr,[],dim); If unsure type: help func
34 Plotting with MATLAB Very flexible plotting tools Many functions for a variety of plot types and graphics drawing ND improvement in respect to p st [%] <= >=100 minimal ND Firing rates Fano Factors (FF) Population FF Burst rates Burst sizes ISI 2 ISI CV(ISI) Synchronization X Corr (distance) Improvement [%] overall (MND) average percent (ND) Parameter # optimized Parameter #
35 Overview Useful plotting commands plot plots all kinds of lines, dots, markers in 2D imagesc plots an 2-D pseudo image errorbar plots dots/line with error bars bar bar plot hist histogram surface 3D surface plot
36 Overview Useful plotting commands plot plots all kinds of lines, dots, markers in 2D imagesc plots an 2-D pseudo image errorbar plots dots/line with error bars bar bar plot hist histogram surface 3D surface plot Note: For an overview of 2D plotting commands: help graph2d Note 2: For fancy graphs see: help specgraph
37 How to plot How to plot: 1 Open a figure (window) with >> figure; 2 Create an axes object with >> axes; 3 Type the plotting command of your choice >> plot(x,y, b--, LineWidth,2); Note: graphics commands draw into the current axes (gca) on the current figure (gcf). They automatically create a new figure and axes if necessary. 4 Make the plot nicer by adding labels and setting limits, eg: >> xlabel( Time [s] ); >> ylabel( Response [spks/sec] ); >> xlim([-1,1]); ylim([-2,2]); >> title( Simulation )
38 plot command Basic syntax: handle = plot(x,y,linespec,optname1,val1,...); X,Y x- and y-values to plot. If Y is a 2-D array, all columns are plotted as different lines linespec a string with a short hand for color and line style and marker type. See help plot for an overview. Eg, linespec = :ko plots dotted (:) black line (k) with a circle at each given coordinate (x i,y i ) optname1 a string specifing the option name, eg. LineWidth val1 a corresponding value. handle graphics handle for later reference, eg. with >> set(handle,optname1,val1) Tip: To get an overview over all possible options, try get(handle)
39 Plotting example: empirical PDF of Gaussian 1 figure ; 2 3 % plot Gaussian PDF 4 x = 4:0.01:4; 5 y = exp( 0.5 x.ˆ2)/ sqrt (2 pi ) ; 6 plot (x, y, k, Linewidth,2); 7 8 % e mpirical pdf 9 % histogram of 1000 random values 10 [N, z]= hist ( randn (1000,1)); 11 %normalization 12 p = N/sum(N)/( z(2) z ( 1 ) ) ; hold on ; %adds a l l f o l l o w i n g graphs 15 %to the current axes 16 plot (z, p, rx, MarkerSize,10); 17 hold o f f ; xlabel ( Random v a r i a b l e x ) 20 ylabel ( P r o b a b i l i t y density ) 21 legend ( true PDF, e m pirical PDF ) Probability density true PDF empirical PDF Random variable x
40 MATLAB is a script language Scripts are blocks of code which can be called within MATLAB or within another script. They are text-files with extensions.m. They should contain all commands associated with a scientific project. (at least to easily reproduce and the calculations)
41 MATLAB is a script language Scripts are blocks of code which can be called within MATLAB or within another script. They are text-files with extensions.m. They should contain all commands associated with a scientific project. (at least to easily reproduce and the calculations) There are basically two types of m-files 1 m-file script A squential list of MATLAB commands The variable scope is that of the caller. 2 m-file function m-file functions accept input parameters and deliver outputs. The variable scope is different from that of the caller.
42 m-file scripts How to write an m-file script?
43 m-file scripts How to write an m-file script? 1 open a text-editor of your choice or use the editor provided with MATLAB >> edit myscript
44 m-file scripts How to write an m-file script? 1 open a text-editor of your choice or use the editor provided with MATLAB >> edit myscript 2 Write all your calculations in a text-file with extension.m (here myscript.m)
45 m-file scripts How to write an m-file script? 1 open a text-editor of your choice or use the editor provided with MATLAB >> edit myscript 2 Write all your calculations in a text-file with extension.m (here myscript.m) 3 Save file in the current working directory (or addpath to search path )
46 m-file scripts How to write an m-file script? 1 open a text-editor of your choice or use the editor provided with MATLAB >> edit myscript 2 Write all your calculations in a text-file with extension.m (here myscript.m) 3 Save file in the current working directory (or addpath to search path ) 4 Call your script by calling it from the Command Window >> myscript; (no compilation needed)
47 m-file scripts How to write an m-file script? 1 open a text-editor of your choice or use the editor provided with MATLAB >> edit myscript 2 Write all your calculations in a text-file with extension.m (here myscript.m) 3 Save file in the current working directory (or addpath to search path ) 4 Call your script by calling it from the Command Window >> myscript; (no compilation needed) 5 Note: The variable scope is that of the caller. This means that the variables of the script are now present in the workspace
48 m-file functions How to write an m-file function?
49 m-file functions How to write an m-file function? Identical to writing an m-file script, except:
50 m-file functions How to write an m-file function? Identical to writing an m-file script, except: In the first line input and output arguments are defined: function outarg = myfun(inarg1,inarg2,...);
51 m-file functions How to write an m-file function? Identical to writing an m-file script, except: In the first line input and output arguments are defined: function outarg = myfun(inarg1,inarg2,...); Call the function with >> result = myfun(p1,p2,...);
52 m-file functions How to write an m-file function? Identical to writing an m-file script, except: In the first line input and output arguments are defined: function outarg = myfun(inarg1,inarg2,...); Call the function with >> result = myfun(p1,p2,...); Note: The variable scope is different from that of the caller. That means, that variables defined in the function body are NOT present in the workspace after calling the function
53 m-file functions How to write an m-file function? Identical to writing an m-file script, except: In the first line input and output arguments are defined: function outarg = myfun(inarg1,inarg2,...); Call the function with >> result = myfun(p1,p2,...); Note: The variable scope is different from that of the caller. That means, that variables defined in the function body are NOT present in the workspace after calling the function Note 2: Input arguments are always referenced by value (although internally MATLAB does not copy a variable as long it is not changed inside function)
54 m-file functions How to write an m-file function? Identical to writing an m-file script, except: In the first line input and output arguments are defined: function outarg = myfun(inarg1,inarg2,...); Call the function with >> result = myfun(p1,p2,...); Note: The variable scope is different from that of the caller. That means, that variables defined in the function body are NOT present in the workspace after calling the function Note 2: Input arguments are always referenced by value (although internally MATLAB does not copy a variable as long it is not changed inside function) Note 3: When called the m-file file name is used.
55 Basic syntax The basic syntax is similar to other script languages MATLAB has the usual flow control structures, namely if.. else for decisions for-loop while-loop switch.. case for multiple if-else decisions try.. catch for handling errors
56 Basic syntax: flow control (1) if-else block syntax: 1 i f s c a l a r c o n d i t i o n 2 expressions 3 else 4 expressions 5 end Relational operators, eg.: == (equals), (or), && (and), ~ (not) for details type: help relop
57 Basic syntax: flow control (1) if-else block syntax: 1 i f s c a l a r c o n d i t i o n 2 expressions 3 else 4 expressions 5 end Relational operators, eg.: == (equals), (or), && (and), ~ (not) for details type: help relop Example (if-else) a = rand ( 1 ) ; i f a == 0.5 fprintf ( you are very lucky! ) ; end
58 Programming: basic flow control (2) for-loop block syntax: 1 for i = array 2 % i==array ( j ) in the j th loop 3 expressions 4 end (one can also use break and continue keywords)
59 Programming: basic flow control (2) for-loop block syntax: 1 for i = array 2 % i==array ( j ) in the j th loop 3 expressions 4 end (one can also use break and continue keywords) Example (for loop) a=0; for i = 1:100 a = a+i ; end
60 MATLAB provides many more things Useful Toolboxes Statistical Toolbox (lots of statistical tests and distributions) Neural Network Toolbox (training networks and much more) Signal Processing Toolbox (a lot of filter designs and spectral methods) Image Processing Toolbox (reading, writing, filtering images) Symbolic maths (Mathematica is more powerful though) Distributed Computing Toolbox (expensive...) Interfaces to C code (MEX) CUDA-kernels (using super-parallel CUDA-GPU hardware) fancy 3D plots
61 Exercises
62 Exercises Exercise (How to write an m-file script) Write an m-file computing the Stirling approximation n! ( n ) n 2πn e Hint: π is defined in MATLAB as pi, and e x as exp(x). Solution Reminder: 1 Open a text-editor >> edit myscript 2 Write calculations in text-file with extension.m 3 Save file into current working directory 4 Call your script >> myscript;
63 Exercises Exercise (p-series) Calculate the p-series (generalization of the Harmonic Series) for a given p up to a given m Use array notation. Solution µ m = m i=1 1 n p Advise: Use array notation and avoid for-loops whereever you can!
64 Exercises Exercise (blob movie) 1 Generate a two arrays with, x and y, ranging from -2 to 2 (and about 100 elements) 2 Generate two 100 by 100 grid-matrices, X and Y using meshgrid with x and y as input (look at X and Y to understand what meshgrid is doing). 3 calculate a matrix Z of the same size as X and Y where each element is given by z i = e (x2 i +y2 i ). 4 write a loop with t ranging from 0 to 1000 where you 1 plot the matrix Z (using imagesc) 2 circular shift the matrix Z by 1 element (using circshift) 3 force the plot to be drawn (using drawnow) Solution
65 Exercises Exercise (Logical indexing and basic plotting) 1 Generate a 100 by 2 matrix M of Gaussian random values 2 Plot a point cloud (first vs. second column of M) using blue circles 3 Calculate how many values of M are positive 4 Erase all rows in M which have at least one negative value 5 Plot the points of the modified array M using red crosses in the same graph as above. 6 Set both axes limits to 3 to 3 and plot dotted gray lines on the coordinate axes (where y = 0 or x = 0). 7 Label the axes and write a legend Solution
66 Exercises Exercise (writing a m-file function) Write an m-file function computing the Stirling approximation n! ( n ) n 2πn e for a given n Solution Reminder: In the first line input and output arguments are defined: function outarg = myfun(inarg1,inarg2,...); Call the function with >> result = myfun(p1,p2,...);
67 Exercises Exercise (Poisson spike trains) Write a function that generates a homogeneous Poisson spike train of rate λ having exactly N spikes. Use array notations (cumsum). Hint: Poisson spike intervals t are exponentially distributed. They can be generated by inverse transform sampling: Given uniform random variables u in 0 to 1 valid inter-spike intervals can be calculated as t = log u λ Solution Advise: Use array notation and avoid for-loops whereever you can!
68 Exercises Exercise (More on spike trains) Generate a long Poisson spike train (with the function from the last exercise). Compute the mean and standard deviation of the inter-spike interval distribution. Further, write a function that counts the number of spike times falling into time-bins of length t. Hint: Use diff to get the intervals from spike times. Hint 2: Use histc to bin the spike-times Solution
69 Exercises Exercise (Plot 2-D Gaussian point cloud) Write a function which plots a point cloud of n random samples drawn from a 2D Normal distribution (with 0 mean) and variance Σ = (RD) T (RD), where the rotation matrix is defined as «cos θ sin θ R = sin θ cos θ and D is a diagonal matrix of the standard deviation in the principal directions «σ1 0 D = 0 σ 2 The function should accept parameters σ 1, σ 2, and θ Hint: use randn to produce independent Normal-distributed random vectors x i and transform them according to y i = RDx i. Solution
70 Exercises Exercise (Simulate LIF-neuron network) Simulate a network of n simple LIF-neurons τ m dv dt = v + (Ws + RI in + RI noise ) and v i = v reset if v i > v thres. The synaptic currents dynamics is simplified as Unit # Time [sec] τ ds i dt = s i + Θ spike where Θ spike = 1 at times where the i-th neuron spikes and 0 otherwise. Connections W are sparse (probability p 0.2) and weights are normal distributed (with standard deviation g). Plot the spikes raster when constantly stimulating for a brief period of time. Hint: use the Euler method to integrate the equations v i (t + 1) = v i (t) + t dv i Solution dt
71 Advanced exercise Exercise (Optimizing MATLAB code) Optimize bad MATLAB code for generating self-organizing maps. See provided code and description in som_exercise.zip.
72 Solution (Writing a m-file script) 1 %compute the S t i r l i n g Formula 2 3 n = 50; 4 5 s t i r f a c n = sqrt (2 pi n ) ( n/exp (1))ˆ n ; 6 fac n = f a c t o r i a l (n ) ; 7 8 %n i c e r output 9 f p r i n t f ( S t i r l i n g approximation for %d! : \ n,n) 10 s t i r f a c n 11 f p r i n t f ( Exact %d! : \ n,n) 12 fac n back to text
73 Solution (p-series) 1 function mu = p s e r i e s (n, p ) ; 2 % PSERIES(N,P) computes the P s e r i e s up to N 3 4 i a r r = (1: n ).ˆ p ; 5 mu = sum(1./ i arr, 2 ) ; back to text
74 Solution (blob movie) 1 x = linspace ( 2,2,100); 2 y = linspace ( 2,2,100); 3 4 [X,Y] = meshgrid (x, y ) ; 5 6 Z = exp( X.ˆ2 Y. ˆ 2 ) ; 7 8 for t = 1: imagesc (Z ) ; 10 Z = c i r c s h i f t (Z, [ 0, 1 ] ) ; 11 drawnow ; 12 end back to text
75 Solution (Logical indexing and basic plotting) 1 %1. 2 M = randn (100,2); 3 4 %2. 5 plot (M(:,1),M(:,2), bo ) ; 6 7 %3. 8 npos = sum(m(:) >0) 9 10 %4. 11 M( any (M<0,2),:) = [ ] ; %5. 14 hold on ; 15 plot (M(:,1),M(:,2), rx ) ; %6. 18 l i m i t s = [ 3,3]; 19 xlim ( l i m i t s ) ; ylim ( l i m i t s ) 20 plot ( l i m i t s, [ 0, 0 ], :, Color, [ 0. 5, 0. 5, 0. 5 ] ) 21 plot ( [ 0, 0 ], l i m i t s, :, Color, [ 0. 5, 0. 5, 0. 5 ] ) %7. 24 xlabel ( X ) 25 ylabel ( Y ) 26 legend ({ Gaussian random samples, Points with X>0 and Y>0 }) back to text
76 Solution (Writing a m-file function) 1 function s t i r f a c n = s t i r f a c (n ) ; 2 %compute the S t i r l i n g Formula 3 4 s t i r f a c n = sqrt (2 pi n ) ( n/exp (1))ˆ n ; back to text
77 Solution (Poisson spike trains) 1 function spkt = poissonspikes ( lambda,n) 2 % SPKT = POISSONSPIKES(LAMBDA,N) generates a 3 % Poisson spike t r a i n with rate LAMBDA 4 % and exactly N spikes. 5 6 i s i s = log ( rand (N,1))/ lambda ; 7 spkt = cumsum( i s i s ) ; back to text
78 Solution (more on spike trains) 1 N = 1000; % number of spikes 2 lambda = 10; %spike rate 3 4 %Poisson spikes 5 spkt = cumsum( log ( rand (N,1))/ lambda ) ; 6 7 %mean of the I S I 8 misi = mean( d i f f ( spkt ) ) ; 9 10 %stddev of the I S I 11 s i s i = std ( d i f f ( spkt ) ) ; function S = spikebinning ( spkt, twin, dt ) 15 % S = SPIKEBINNING(SPKT,TWIN,DT) counts the spike times 16 % occurring in each bin of width DT in the time window 17 % from TWIN(1) and TWIN(2) S = h i s t c ( spkt, twin ( 1 ) : dt : twin ( 2 ) ) ; back to text
79 Solution (plot 2-D Gaussian point cloud) 1 function plot2dgaussian ( sig1, sig2, theta ) ; 2 % PLOT2DGAUSSIAN( SIG1, SIG2,THETA) p l o t s a Gaussian point cloud with 3 % standard d e v i a t i o n s SIG1 and SIG2 and o r i e n t a t i o n THETA. 4 5 n = 250; 6 r = randn (2, n ) ; 7 D = [ sig1, 0;0, sig2 ] ; 8 R = [ cos ( theta ), sin ( theta ) ; sin ( theta ), cos ( theta ) ] ; 9 10 x = R D r ; %p l o t t i n g 13 figure ; subplot (2,2,1); 14 plot ( x (1,:), x (2,:),. b, MarkerSize,6); %r e s i z e the axes 17 mxlen = 1.1 max( abs ( x ( : ) ) ) ; 18 xlim ([ mxlen, mxlen ] ) 19 ylim ([ mxlen, mxlen ] ) %plo t the 0 coordinates 22 hold on ; 23 plot ([ mxlen, mxlen ], [ 0, 0 ], k ) 24 plot ([0,0],[ mxlen, mxlen ], k ) 25 hold o f f ; back to text
80 Solution (simulate LIF-neuron network) 1 %parameters 2 n = 50; % number of neurons 3 p = 0.25; % prob. of connection 4 vthres = 0. 2 ; 5 v reset = 0.05; 6 s i g I = 0. 5 ; % input noise strength 7 tau s = 1; % synaptic time const. 8 g = 1; % weight s c a l e 9 tau m = 1; % membrane time const. 10 R = 1; % r e s i s t a n c e 11 dt = 0.05; % time step 12 tmax = 10; 13 tinput = [ 2, 6 ] ;% input time i n t e r v a l 14 I i n p u t = 0. 3 ; % input strength %connections j u s t random 18 connif = rand (n, n)<=p ; 19 %weights normal d i s t r i b u t i o n 20 W = g randn (n, n ). connif ; %i n i t i a l i z e v a r i a b l e s 23 t = 0: dt : tmax ; 24 spks = zeros (n, size ( t, 2 ) ) ; 25 v = zeros (n, 1 ) ; % voltage 26 s = zeros (n, 1 ) ; % synaptic current %Euler i n t e g r a t i o n 30 for i = 1: size ( t,2) 31 %noise + input 32 I = s i g I randn (n, 1 ) ; 33 i f t ( i)>=tinput (1) && t ( i)<tinput (2) 34 I = I + I i n p u t ; 35 end 36 %voltage update 37 dv = v + W s + R I ; 38 v = v + dv dt/tau m ; %find spikes and set to v reset 41 spks ( :, i ) = v>vthres ; 42 v ( find ( spks ( :, i ))) = v reset ; %update s 45 ds = s + spks ( :, i ) ; 46 s = s + dt/ tau s ds ; 47 end %plot spikes 50 [X,Y] = meshgrid ( t, 1 : n ) ; 51 idx = find ( spks ( : ) ) ; 52 plot (X( idx ),Y( idx ), x ) ; 53 xlim ([0, tmax ] ) ; ylim ([0, n ] ) 54 xlabel ( Time [ sec ] ) 55 ylabel ( Unit # ) back to text
MATLAB Tutorial CCN Course 2012
MATLAB Tutorial CCN Course 2012 How to code a neural network simulation Malte J. Rasch National Key Laboratory of Cognitive Neuroscience and Learning Beijing Normal University China July 17, 2012 Overview
More informationMATLAB Tutorial CCN Course 2012
MATLAB Tutorial CCN Course 2012 How to code a neural network simulation Malte J. Rasch National Key Laboratory of Cognitive Neuroscience and Learning Beijing Normal University China July 17, 2012 Overview
More informationIntroduction to Octave/Matlab. Deployment of Telecommunication Infrastructures
Introduction to Octave/Matlab Deployment of Telecommunication Infrastructures 1 What is Octave? Software for numerical computations and graphics Particularly designed for matrix computations Solving equations,
More informationENGR Fall Exam 1
ENGR 1300 Fall 01 Exam 1 INSTRUCTIONS: Duration: 60 minutes Keep your eyes on your own work! Keep your work covered at all times! 1. Each student is responsible for following directions. Read carefully..
More informationPART 1 PROGRAMMING WITH MATHLAB
PART 1 PROGRAMMING WITH MATHLAB Presenter: Dr. Zalilah Sharer 2018 School of Chemical and Energy Engineering Universiti Teknologi Malaysia 23 September 2018 Programming with MATHLAB MATLAB Environment
More information1. Register an account on: using your Oxford address
1P10a MATLAB 1.1 Introduction MATLAB stands for Matrix Laboratories. It is a tool that provides a graphical interface for numerical and symbolic computation along with a number of data analysis, simulation
More informationIntroduction to Matlab
Introduction to Matlab By:Mohammad Sadeghi *Dr. Sajid Gul Khawaja Slides has been used partially to prepare this presentation Outline: What is Matlab? Matlab Screen Basic functions Variables, matrix, indexing
More informationAMS 27L LAB #2 Winter 2009
AMS 27L LAB #2 Winter 2009 Plots and Matrix Algebra in MATLAB Objectives: 1. To practice basic display methods 2. To learn how to program loops 3. To learn how to write m-files 1 Vectors Matlab handles
More informationIntroduction to MatLab. Introduction to MatLab K. Craig 1
Introduction to MatLab Introduction to MatLab K. Craig 1 MatLab Introduction MatLab and the MatLab Environment Numerical Calculations Basic Plotting and Graphics Matrix Computations and Solving Equations
More informationPractical 4: The Integrate & Fire neuron
Practical 4: The Integrate & Fire neuron 2014 version by Mark van Rossum 2018 version by Matthias Hennig and Theoklitos Amvrosiadis 16th October 2018 1 Introduction to MATLAB basics You can start MATLAB
More informationENGR Fall Exam 1
ENGR 13100 Fall 2012 Exam 1 INSTRUCTIONS: Duration: 60 minutes Keep your eyes on your own work! Keep your work covered at all times! 1. Each student is responsible for following directions. Read carefully.
More informationSome elements for Matlab programming
Some elements for Matlab programming Nathalie Thomas 2018 2019 Matlab, which stands for the abbreviation of MATrix LABoratory, is one of the most popular language for scientic computation. The classical
More informationWhat is MATLAB? It is a high-level programming language. for numerical computations for symbolic computations for scientific visualizations
What is MATLAB? It stands for MATrix LABoratory It is developed by The Mathworks, Inc (http://www.mathworks.com) It is an interactive, integrated, environment for numerical computations for symbolic computations
More informationObjectives. 1 Running, and Interface Layout. 2 Toolboxes, Documentation and Tutorials. 3 Basic Calculations. PS 12a Laboratory 1 Spring 2014
PS 12a Laboratory 1 Spring 2014 Objectives This session is a tutorial designed to a very quick overview of some of the numerical skills that you ll need to get started. Throughout the tutorial, the instructors
More informationENGR Fall Exam 1 PRACTICE EXAM
ENGR 13100 Fall 2012 Exam 1 PRACTICE EXAM INSTRUCTIONS: Duration: 60 minutes Keep your eyes on your own work! Keep your work covered at all times! 1. Each student is responsible for following directions.
More informationAppendix A. Introduction to MATLAB. A.1 What Is MATLAB?
Appendix A Introduction to MATLAB A.1 What Is MATLAB? MATLAB is a technical computing environment developed by The Math- Works, Inc. for computation and data visualization. It is both an interactive system
More informationCSCI 6906: Fundamentals of Computational Neuroimaging. Thomas P. Trappenberg Dalhousie University
CSCI 6906: Fundamentals of Computational Neuroimaging Thomas P. Trappenberg Dalhousie University 1 Programming with Matlab This chapter is a brief introduction to programming with the Matlab programming
More informationAN INTRODUCTION TO MATLAB
AN INTRODUCTION TO MATLAB 1 Introduction MATLAB is a powerful mathematical tool used for a number of engineering applications such as communication engineering, digital signal processing, control engineering,
More informationIntroduction to MATLAB Practical 1
Introduction to MATLAB Practical 1 Daniel Carrera November 2016 1 Introduction I believe that the best way to learn Matlab is hands on, and I tried to design this practical that way. I assume no prior
More informationHow to learn MATLAB? Some predefined variables
ECE-S352 Lab 1 MATLAB Tutorial How to learn MATLAB? 1. MATLAB comes with good tutorial and detailed documents. a) Select MATLAB help from the MATLAB Help menu to open the help window. Follow MATLAB s Getting
More informationNumerical Methods in Engineering Sciences
Numerical Methods in Engineering Sciences Lecture 1: Brief introduction to MATLAB Pablo Antolin pablo.antolinsanchez@unipv.it October 29th 2013 How many of you have used MATLAB before? How many of you
More informationMATLAB Lesson I. Chiara Lelli. October 2, Politecnico di Milano
MATLAB Lesson I Chiara Lelli Politecnico di Milano October 2, 2012 MATLAB MATLAB (MATrix LABoratory) is an interactive software system for: scientific computing statistical analysis vector and matrix computations
More informationA Guide to Using Some Basic MATLAB Functions
A Guide to Using Some Basic MATLAB Functions UNC Charlotte Robert W. Cox This document provides a brief overview of some of the essential MATLAB functionality. More thorough descriptions are available
More informationInformation for Candidates. Test Format
Information for Candidates Test Format The MathWorks Certified MATLAB Professional (MCMP) exam consists of two sections: 25 multiplechoice questions and 8 performance-based problems. MATLAB access is not
More informationMatlab Tutorial and Exercises for COMP61021
Matlab Tutorial and Exercises for COMP61021 1 Introduction This is a brief Matlab tutorial for students who have not used Matlab in their programming. Matlab programming is essential in COMP61021 as a
More informationMatlab Tutorial for COMP24111 (includes exercise 1)
Matlab Tutorial for COMP24111 (includes exercise 1) 1 Exercises to be completed by end of lab There are a total of 11 exercises through this tutorial. By the end of the lab, you should have completed the
More informationExperiment 1: Introduction to MATLAB I. Introduction. 1.1 Objectives and Expectations: 1.2 What is MATLAB?
Experiment 1: Introduction to MATLAB I Introduction MATLAB, which stands for Matrix Laboratory, is a very powerful program for performing numerical and symbolic calculations, and is widely used in science
More informationIntroduction to Matlab. Summer School CEA-EDF-INRIA 2011 of Numerical Analysis
Introduction to Matlab 1 Outline What is Matlab? Matlab desktop & interface Scalar variables Vectors and matrices Exercise 1 Booleans Control structures File organization User defined functions Exercise
More informationSF1901 Probability Theory and Statistics: Autumn 2016 Lab 0 for TCOMK
Mathematical Statistics SF1901 Probability Theory and Statistics: Autumn 2016 Lab 0 for TCOMK 1 Preparation This computer exercise is a bit different from the other two, and has some overlap with computer
More informationIntroduction to MATLAB LAB 1
Introduction to MATLAB LAB 1 1 Basics of MATLAB MATrix LABoratory A super-powerful graphing calculator Matrix based numeric computation Embedded Functions Also a programming language User defined functions
More informationIntroduction to Matlab
Introduction to Matlab November 22, 2013 Contents 1 Introduction to Matlab 1 1.1 What is Matlab.................................. 1 1.2 Matlab versus Maple............................... 2 1.3 Getting
More informationIntroduction to Matlab
What is Matlab? Introduction to Matlab Matlab is software written by a company called The Mathworks (mathworks.com), and was first created in 1984 to be a nice front end to the numerical routines created
More informationIntroduction to Matlab. By: Dr. Maher O. EL-Ghossain
Introduction to Matlab By: Dr. Maher O. EL-Ghossain Outline: q What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display Facilities Flow Control
More informationWhat is MATLAB and howtostart it up?
MAT rix LABoratory What is MATLAB and howtostart it up? Object-oriented high-level interactive software package for scientific and engineering numerical computations Enables easy manipulation of matrix
More informationWhat is MATLAB? What is MATLAB? Programming Environment MATLAB PROGRAMMING. Stands for MATrix LABoratory. A programming environment
What is MATLAB? MATLAB PROGRAMMING Stands for MATrix LABoratory A software built around vectors and matrices A great tool for numerical computation of mathematical problems, such as Calculus Has powerful
More informationMATLAB Introductory Course Computer Exercise Session
MATLAB Introductory Course Computer Exercise Session This course is a basic introduction for students that did not use MATLAB before. The solutions will not be collected. Work through the course within
More informationIntroduction to MATLAB Programming
Introduction to MATLAB Programming Arun A. Balakrishnan Asst. Professor Dept. of AE&I, RSET Overview 1 Overview 2 Introduction 3 Getting Started 4 Basics of Programming Overview 1 Overview 2 Introduction
More informationMATLAB Tutorial. Digital Signal Processing. Course Details. Topics. MATLAB Environment. Introduction. Digital Signal Processing (DSP)
Digital Signal Processing Prof. Nizamettin AYDIN naydin@yildiz.edu.tr naydin@ieee.org http://www.yildiz.edu.tr/~naydin Course Details Course Code : 0113620 Course Name: Digital Signal Processing (Sayısal
More informationIntroduction to MATLAB programming: Fundamentals
Introduction to MATLAB programming: Fundamentals Shan He School for Computational Science University of Birmingham Module 06-23836: Computational Modelling with MATLAB Outline Outline of Topics Why MATLAB?
More informationObjectives. 1 Basic Calculations. 2 Matrix Algebra. Physical Sciences 12a Lab 0 Spring 2016
Physical Sciences 12a Lab 0 Spring 2016 Objectives This lab is a tutorial designed to a very quick overview of some of the numerical skills that you ll need to get started in this class. It is meant to
More informationPart VI. Scientific Computing in Python. Alfredo Parra : Scripting with Python Compact Max-PlanckMarch 6-10,
Part VI Scientific Computing in Python Compact Course @ Max-PlanckMarch 6-10, 2017 63 Doing maths in Python Standard sequence types (list, tuple,... ) Can be used as arrays Can contain different types
More informationIntroduction to Matlab
Introduction to Matlab What is Matlab The software program called Matlab (short for MATrix LABoratory) is arguably the world standard for engineering- mainly because of its ability to do very quick prototyping.
More informationMath 375 Natalia Vladimirova (many ideas, examples, and excersises are borrowed from Profs. Monika Nitsche, Richard Allen, and Stephen Lau)
Natalia Vladimirova (many ideas, examples, and excersises are borrowed from Profs. Monika Nitsche, Richard Allen, and Stephen Lau) January 24, 2010 Starting Under windows Click on the Start menu button
More informationMAT 275 Laboratory 1 Introduction to MATLAB
MATLAB sessions: Laboratory 1 1 MAT 275 Laboratory 1 Introduction to MATLAB MATLAB is a computer software commonly used in both education and industry to solve a wide range of problems. This Laboratory
More informationMATLAB BASICS. < Any system: Enter quit at Matlab prompt < PC/Windows: Close command window < To interrupt execution: Enter Ctrl-c.
MATLAB BASICS Starting Matlab < PC: Desktop icon or Start menu item < UNIX: Enter matlab at operating system prompt < Others: Might need to execute from a menu somewhere Entering Matlab commands < Matlab
More information1 Introduction to Matlab
1 Introduction to Matlab 1. What is Matlab? Matlab is a computer program designed to do mathematics. You might think of it as a super-calculator. That is, once Matlab has been started, you can enter computations,
More informationMATLAB Basics. Configure a MATLAB Package 6/7/2017. Stanley Liang, PhD York University. Get a MATLAB Student License on Matworks
MATLAB Basics Stanley Liang, PhD York University Configure a MATLAB Package Get a MATLAB Student License on Matworks Visit MathWorks at https://www.mathworks.com/ It is recommended signing up with a student
More informationA Brief Introduction to MATLAB
A Brief Introduction to MATLAB MATLAB (Matrix Laboratory) is an interactive software system for numerical computations and graphics. As the name suggests, MATLAB was first designed for matrix computations:
More informationProgramming in Mathematics. Mili I. Shah
Programming in Mathematics Mili I. Shah Starting Matlab Go to http://www.loyola.edu/moresoftware/ and login with your Loyola name and password... Matlab has eight main windows: Command Window Figure Window
More informationUNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER
UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER BENC 2113 DENC ECADD 2532 ECADD LAB SESSION 6/7 LAB
More informationLecturer: Keyvan Dehmamy
MATLAB Tutorial Lecturer: Keyvan Dehmamy 1 Topics Introduction Running MATLAB and MATLAB Environment Getting help Variables Vectors, Matrices, and linear Algebra Mathematical Functions and Applications
More informationIntroduction to MATLAB
58:110 Computer-Aided Engineering Spring 2005 Introduction to MATLAB Department of Mechanical and industrial engineering January 2005 Topics Introduction Running MATLAB and MATLAB Environment Getting help
More informationCDA5530: Performance Models of Computers and Networks. Chapter 8: Using Matlab for Performance Analysis and Simulation
CDA5530: Performance Models of Computers and Networks Chapter 8: Using Matlab for Performance Analysis and Simulation Objective Learn a useful tool for mathematical analysis and simulation Interpreted
More informationMATLAB Tutorial. Mohammad Motamed 1. August 28, generates a 3 3 matrix.
MATLAB Tutorial 1 1 Department of Mathematics and Statistics, The University of New Mexico, Albuquerque, NM 87131 August 28, 2016 Contents: 1. Scalars, Vectors, Matrices... 1 2. Built-in variables, functions,
More informationGetting Started with MATLAB
Getting Started with MATLAB Math 315, Fall 2003 Matlab is an interactive system for numerical computations. It is widely used in universities and industry, and has many advantages over languages such as
More informationCDA6530: Performance Models of Computers and Networks. Chapter 4: Using Matlab for Performance Analysis and Simulation
CDA6530: Performance Models of Computers and Networks Chapter 4: Using Matlab for Performance Analysis and Simulation Objective Learn a useful tool for mathematical analysis and simulation Interpreted
More informationThis is a basic tutorial for the MATLAB program which is a high-performance language for technical computing for platforms:
Appendix A Basic MATLAB Tutorial Extracted from: http://www1.gantep.edu.tr/ bingul/ep375 http://www.mathworks.com/products/matlab A.1 Introduction This is a basic tutorial for the MATLAB program which
More informationINTRODUCTORY NOTES ON MATLAB
INTRODUCTORY NOTES ON MATLAB C Lamas Fernández, S Marelli, B Sudret CHAIR OF RISK, SAFETY AND UNCERTAINTY QUANTIFICATION STEFANO-FRANSCINI-PLATZ 5 CH-8093 ZÜRICH Risk, Safety & Uncertainty Quantification
More informationIntroduction to Matlab
Introduction to Matlab Enrique Muñoz Ballester Dipartimento di Informatica via Bramante 65, 26013 Crema (CR), Italy enrique.munoz@unimi.it Contact Email: enrique.munoz@unimi.it Office: Room BT-43 Industrial,
More informationInteractive Computing with Matlab. Gerald W. Recktenwald Department of Mechanical Engineering Portland State University
Interactive Computing with Matlab Gerald W. Recktenwald Department of Mechanical Engineering Portland State University gerry@me.pdx.edu Starting Matlab Double click on the Matlab icon, or on unix systems
More informationMATLAB GUIDE UMD PHYS375 FALL 2010
MATLAB GUIDE UMD PHYS375 FALL 200 DIRECTORIES Find the current directory you are in: >> pwd C:\Documents and Settings\ian\My Documents\MATLAB [Note that Matlab assigned this string of characters to a variable
More informationLecture 2: Variables, Vectors and Matrices in MATLAB
Lecture 2: Variables, Vectors and Matrices in MATLAB Dr. Mohammed Hawa Electrical Engineering Department University of Jordan EE201: Computer Applications. See Textbook Chapter 1 and Chapter 2. Variables
More informationMBI REU Matlab Tutorial
MBI REU Matlab Tutorial Lecturer: Reginald L. McGee II, Ph.D. June 8, 2017 MATLAB MATrix LABoratory MATLAB is a tool for numerical computation and visualization which allows Real & Complex Arithmetics
More informationMATLAB Tutorial. 1. The MATLAB Windows. 2. The Command Windows. 3. Simple scalar or number operations
MATLAB Tutorial The following tutorial has been compiled from several resources including the online Help menu of MATLAB. It contains a list of commands that will be directly helpful for understanding
More informationMATLAB SUMMARY FOR MATH2070/2970
MATLAB SUMMARY FOR MATH2070/2970 DUNCAN SUTHERLAND 1. Introduction The following is inted as a guide containing all relevant Matlab commands and concepts for MATH2070 and 2970. All code fragments should
More informationECON 502 INTRODUCTION TO MATLAB Nov 9, 2007 TA: Murat Koyuncu
ECON 502 INTRODUCTION TO MATLAB Nov 9, 2007 TA: Murat Koyuncu 0. What is MATLAB? 1 MATLAB stands for matrix laboratory and is one of the most popular software for numerical computation. MATLAB s basic
More informationMatlab Tutorial 1: Working with variables, arrays, and plotting
Matlab Tutorial 1: Working with variables, arrays, and plotting Setting up Matlab First of all, let's make sure we all have the same layout of the different windows in Matlab. Go to Home Layout Default.
More informationIntroduction to Matlab. By: Hossein Hamooni Fall 2014
Introduction to Matlab By: Hossein Hamooni Fall 2014 Why Matlab? Data analytics task Large data processing Multi-platform, Multi Format data importing Graphing Modeling Lots of built-in functions for rapid
More informationSTAT 391 Handout 1 Making Plots with Matlab Mar 26, 2006
STAT 39 Handout Making Plots with Matlab Mar 26, 26 c Marina Meilă & Lei Xu mmp@cs.washington.edu This is intended to help you mainly with the graphics in the homework. Matlab is a matrix oriented mathematics
More informationHomework 1 Description CmpE 362 Spring Instructor : Fatih Alagoz Teaching Assistant : Yekta Said Can Due: 3 March, 23:59, sharp
Homework 1 Description CmpE 362 Spring 2016 Instructor : Fatih Alagoz Teaching Assistant : Yekta Said Can Due: 3 March, 23:59, sharp Homework 1 This homework is designed to teach you to think in terms
More informationMATLAB: The greatest thing ever. Why is MATLAB so great? Nobody s perfect, not even MATLAB. Prof. Dionne Aleman. Excellent matrix/vector handling
MATLAB: The greatest thing ever Prof. Dionne Aleman MIE250: Fundamentals of object-oriented programming University of Toronto MIE250: Fundamentals of object-oriented programming (Aleman) MATLAB 1 / 1 Why
More informationOctave Tutorial Machine Learning WS 12/13 Umer Khan Information Systems and Machine Learning Lab (ISMLL) University of Hildesheim, Germany
Octave Tutorial Machine Learning WS 12/13 Umer Khan Information Systems and Machine Learning Lab (ISMLL) University of Hildesheim, Germany 1 Basic Commands Try Elementary arithmetic operations: 5+6, 3-2,
More informationIntroduction to MATLAB
Introduction to MATLAB 1 Introduction to MATLAB A Tutorial for the Course Computational Intelligence http://www.igi.tugraz.at/lehre/ci Stefan Häusler Institute for Theoretical Computer Science Inffeldgasse
More informationClass #15: Experiment Introduction to Matlab
Class #15: Experiment Introduction to Matlab Purpose: The objective of this experiment is to begin to use Matlab in our analysis of signals, circuits, etc. Background: Before doing this experiment, students
More informationMATLAB TUTORIAL WORKSHEET
MATLAB TUTORIAL WORKSHEET What is MATLAB? Software package used for computation High-level programming language with easy to use interactive environment Access MATLAB at Tufts here: https://it.tufts.edu/sw-matlabstudent
More informationMATLAB Functions and Graphics
Functions and Graphics We continue our brief overview of by looking at some other areas: Functions: built-in and user defined Using M-files to store and execute statements and functions A brief overview
More informationMatLab Just a beginning
MatLab Just a beginning P.Kanungo Dept. of E & TC, C.V. Raman College of Engineering, Bhubaneswar Introduction MATLAB is a high-performance language for technical computing. MATLAB is an acronym for MATrix
More informationCSE/Math 485 Matlab Tutorial and Demo
CSE/Math 485 Matlab Tutorial and Demo Some Tutorial Information on MATLAB Matrices are the main data element. They can be introduced in the following four ways. 1. As an explicit list of elements. 2. Generated
More informationLaboratory 1 Octave Tutorial
Signals, Spectra and Signal Processing Laboratory 1 Octave Tutorial 1.1 Introduction The purpose of this lab 1 is to become familiar with the GNU Octave 2 software environment. 1.2 Octave Review All laboratory
More informationINTRODUCTION TO NUMERICAL ANALYSIS
INTRODUCTION TO NUMERICAL ANALYSIS Cho, Hyoung Kyu Department of Nuclear Engineering Seoul National University 0. MATLAB USAGE 1. Background MATLAB MATrix LABoratory Mathematical computations, modeling
More informationIntroduction to MATLAB. Simon O Keefe Non-Standard Computation Group
Introduction to MATLAB Simon O Keefe Non-Standard Computation Group sok@cs.york.ac.uk Content n An introduction to MATLAB n The MATLAB interfaces n Variables, vectors and matrices n Using operators n Using
More informationPython Crash Course Numpy, Scipy, Matplotlib
Python Crash Course Numpy, Scipy, Matplotlib That is what learning is. You suddenly understand something you ve understood all your life, but in a new way. Doris Lessing Steffen Brinkmann Max-Planck-Institut
More informationMATLAB Tutorial EE351M DSP. Created: Thursday Jan 25, 2007 Rayyan Jaber. Modified by: Kitaek Bae. Outline
MATLAB Tutorial EE351M DSP Created: Thursday Jan 25, 2007 Rayyan Jaber Modified by: Kitaek Bae Outline Part I: Introduction and Overview Part II: Matrix manipulations and common functions Part III: Plots
More informationELEC4042 Signal Processing 2 MATLAB Review (prepared by A/Prof Ambikairajah)
Introduction ELEC4042 Signal Processing 2 MATLAB Review (prepared by A/Prof Ambikairajah) MATLAB is a powerful mathematical language that is used in most engineering companies today. Its strength lies
More informationCDA6530: Performance Models of Computers and Networks. Chapter 4: Using Matlab for Performance Analysis and Simulation
CDA6530: Performance Models of Computers and Networks Chapter 4: Using Matlab for Performance Analysis and Simulation Objective Learn a useful tool for mathematical analysis and simulation Interpreted
More informationChapter 2. MATLAB Fundamentals
Chapter 2. MATLAB Fundamentals Choi Hae Jin Chapter Objectives q Learning how real and complex numbers are assigned to variables. q Learning how vectors and matrices are assigned values using simple assignment,
More informationMatlab programming, plotting and data handling
Matlab programming, plotting and data handling Andreas C. Kapourani (Credit: Steve Renals & Iain Murray) 25 January 27 Introduction In this lab session, we will continue with some more sophisticated matrix
More informationMATLAB BASICS. M Files. Objectives
Objectives MATLAB BASICS 1. What is MATLAB and why has it been selected to be the tool of choice for DIP? 2. What programming environment does MATLAB offer? 3. What are M-files? 4. What is the difference
More informationPowerPoints organized by Dr. Michael R. Gustafson II, Duke University
Part 1 Chapter 2 MATLAB Fundamentals PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
More informationEvolutionary Algorithms. Workgroup 1
The workgroup sessions Evolutionary Algorithms Workgroup Workgroup 1 General The workgroups are given by: Hao Wang - h.wang@liacs.leideuniv.nl - Room 152 Furong Ye - f.ye@liacs.leidenuniv.nl Follow the
More informationMATLAB: The Basics. Dmitry Adamskiy 9 November 2011
MATLAB: The Basics Dmitry Adamskiy adamskiy@cs.rhul.ac.uk 9 November 2011 1 Starting Up MATLAB Windows users: Start up MATLAB by double clicking on the MATLAB icon. Unix/Linux users: Start up by typing
More informationDr Richard Greenaway
SCHOOL OF PHYSICS, ASTRONOMY & MATHEMATICS 4PAM1008 MATLAB 2 Basic MATLAB Operation Dr Richard Greenaway 2 Basic MATLAB Operation 2.1 Overview 2.1.1 The Command Line In this Workshop you will learn how
More information(1) Generate 1000 samples of length 1000 drawn from the uniform distribution on the interval [0, 1].
PRACTICAL EXAMPLES: SET 1 (1) Generate 1000 samples of length 1000 drawn from the uniform distribution on the interval [0, 1]. >> T=rand(1000,1000); The command above generates a matrix, whose columns
More informationPart VI. Scientific Computing in Python. Tobias Neckel: Scripting with Bash and Python Compact Max-Planck, February 16-26,
Part VI Scientific Computing in Python Compact Course @ Max-Planck, February 16-26, 2015 81 More on Maths Module math Constants pi and e Functions that operate on int and float All return values float
More informationMatlab Tutorial. The value assigned to a variable can be checked by simply typing in the variable name:
1 Matlab Tutorial 1- What is Matlab? Matlab is a powerful tool for almost any kind of mathematical application. It enables one to develop programs with a high degree of functionality. The user can write
More informationMATH (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab
MATH 495.3 (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab Below is a screen similar to what you should see when you open Matlab. The command window is the large box to the right containing the
More informationMathematical Operations with Arrays and Matrices
Mathematical Operations with Arrays and Matrices Array Operators (element-by-element) (important) + Addition A+B adds B and A - Subtraction A-B subtracts B from A.* Element-wise multiplication.^ Element-wise
More informationINTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX
INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX 1) Objective The objective of this lab is to review how to access Matlab, Simulink, and the Communications Toolbox, and to become familiar
More informationMatlab and Psychophysics Toolbox Seminar Part 1. Introduction to Matlab
Keith Schneider, 20 July 2006 Matlab and Psychophysics Toolbox Seminar Part 1. Introduction to Matlab Variables Scalars >> 1 1 Row vector >> [1 2 3 4 5 6] 1 2 3 4 5 6 >> [1,2,3,4,5,6] Column vector 1 2
More informationGetting Started. Chapter 1. How to Get Matlab. 1.1 Before We Begin Matlab to Accompany Lay s Linear Algebra Text
Chapter 1 Getting Started How to Get Matlab Matlab physically resides on each of the computers in the Olin Hall labs. See your instructor if you need an account on these machines. If you are going to go
More information