Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Practical 1: Installation of MATLAB

MATLABs setup is hosted by PEC University. So, we can follow the following instructions to install the software on our systems. 1. Open Run shortcut from the start menu

2. Since MATLAB is hosted by the PEC University on the local network, we can install it without using a disc

3. Proceed through the installation steps as shown

4. Use the installation key as provided by PEC University. Choose the installation type as typical to proceed through a regular MATLAB installation.

5. Give an appropriate folder location for installation.

6. When the installation completes, an icon would be created on the desktop. We can run MATLAB from there.

Practical 2: First MATLAB session


Start MATLAB by clicking the icon on the desktop.
1. Using Vectors in MATLAB.

A vector is a single array of values. We can declare a vector using square brackets at the console prompt (>>>) >>> vector1 = [1, 2, 4, 5, 6] This command declares a vector with five elements. 2. Declaring matrices Matrices can declared using a notation very similar to vectors but separating rows using a semicolon (;) >>> matrix1 = [1, 2, 3; 4, 5, 6; 7, 8, 9] The above command declares a 3x3 matrix with elements from 1 to 9. 3. Operations on matrices and vectors 1. Add two vectors using the + operator. This adds corresponding elements of the vectors together. >>> v1 = [1, 2, 3, 4, 5] >>> v2 = [5, 4, 3, 2, 1] >>> v1 + v2 Ans = [6, 6, 6, 6, 6] 2. Various matrix operations are inbuilt into MATLAB as matrix functions. >>> matrix1 = [1, 2, 3; 4, 5, 6; 7, 8, 9] >>> inv(A)

ans =

-0.4504 0.9007 -0.4504 0.9007 -1.8014 0.9007 -0.4504 0.9007 -0.4504

>>> matrix1 ans = 1 2 3 4 5 6 7 8 9

The above function calculates the transpose of the matrix.

Practical 3: Creating an Artificial Neuron


We can create a neuron in MATLAB by defining a simple function that behaves like an artificial neuron. We first define a function to create an interface to accept the inputs and the corresponding weights of the inputs. Once we have the inputs, we apply them to the neuron which is defined in another function. The neuron is defined as a collection of activation function and the summation of input parameters. The activation function has a predefined threshold that it follows and accordingly fires the neuron. The code for the neuron is as follows:
function [ output ] = neuronA( ) %UNTITLED2 Summary of this function goes here % Detailed explanation goes here p1= input('Input1:'); w1= input('Weight1;'); p2= input('Input2:'); w2= input('weight2:'); thres = input('threshold:'); output = act_func(p1,w1,p2,w2,thres); end

Function to activate the neuron:


function [ fires ] = act_func( p1,w1,p2,w2,thres ) %UNTITLED3 Summary of this function goes here % Detailed explanation goes here sum= (p1*w1) + (p2*w2); fires =0; if sum >= thres; fires=1; end end

You might also like