September 2017

## EEE 306 Lab 8 : Introduction to Matlab

This Lab is about an introduction to matlab.

The objective of this lab is to learn about

• Basic mathematical and logical operator in matlab
• Working with Matrix and vector
• Use of conditional ‘if’
• Use of for and while loop

Practice script

``` %Basic matrix operation
a=[1 2 3;4 5 6;7 8 9]
b=[3 2 1;6 5 4;9 8 7]
c=a+b
d=a*b
n=5
e=a+n*c

%Use of if, while and for
%while 1 %Try not to use while 1 in matlab. It is not a good idea.
total=0
for i=0:1:5
mark= input('What is the mark ')

if mark >=90
point=5;
elseif mark>=80
point=4;
elseif mark>=70
point=3;
elseif mark>=60
point=2;
elseif mark>=50
point=1;
else
point=0;
end % end of if
total=total+point;
end %end of for loop

total=total/6

%end % end for while loop```

MATLAB intro

## EEE 306 Lab 7 : Open methods for finding roots

Write a program to use fixed point iteration to solve the equation f(x)=e^(-x) – x where inputs will be the initial guess, maximum number of iterations and maximum error (es). If the approximation error (ea) is less than es your program should stop continuing any iterations.

Write a program to use Newton Raphson Method to solve the equation f(x)=e^(-x) – x where inputs will be the initial guess, maximum number of iterations and maximum error (es). If the approximation error (ea) is less than es your program should stop continuing any iterations.

Write a program to useĀ  Secant Method to solve the equation f(x)=e^(-x) – x where inputs will be the initial guess, maximum number of iterations and maximum error (es). If the approximation error (ea) is less than es your program should stop continuing any iterations.

## CSE 505 Term Test 2

Date: Tuesday, 25th September 2017

Syllabus: Lecture 4,5,6,7

Question: [Still to come]

Marks: [Still to come]

## CSE 305 Term Test 2

Date: Tuesday, 23rd September 2017

Syllabus: Lecture 4,5,6

Question: [Still to come]

Marks: [Still to come]

## CSE 505 Lab 7

Practise #1 (Section 6.5)
Write a code to take a string input and print the first and last capital letters in the string in alphabatical order

```//code
TITLE First and last capitals
.MODEL SMALL ; DIRECTIVE
.STACK 100H
.DATA ;
CR EQU 0DH ;
LF EQU 0AH ;
;A DW 2 ; DATA SEGMENT
;B DW 5 ;
;SUM DW ? ;
msg db 'Type a line of text',cr,lf,'\$'
msg_nocap db cr,lf,'There is no capital\$'
cap_msg db cr,lf, 'First Capital = '
first db ']'
db ' Last Capital = '
last db '@\$'

.CODE ;
MAIN PROC ;MAIN PROCEDURE ; CODE SEGMENT
MOV AX,@DATA ;
MOV DS, AX ;

mov ah, 9
lea dx, msg
int 21h

MOV AH, 1
INT 21h
while:
cmp al, cr
je end_while

;STaring of if statement
;if
cmp al,'A'
jnge end_if
cmp al, 'Z'
jnle end_if
;then
cmp al, first
jnl check_last
mov first, al

check_last:
cmp al, last
jng end_if
mov last,al

end_if:

int 21h
jmp while
end_while:

mov ah, 9

cmp first,']'
jne cap

lea dx, msg_nocap
jmp display

cap:
lea dx, cap_msg

display:

int 21h

;Exit code
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN```

Problem #1
Write a code to take a string input and print the first and last capital letters in the string as appeared in the string

Example
input:
Hello this is a test A
output:
First capital = H Last capital = A

Problem #2

Dispay the extended ascii characters from 80h to FFh with only 10 ascii characters per line with a space between each characters.