0% found this document useful (0 votes)
15 views

Assignment 1 Razee

The document contains 3 MATLAB assignments. The first assignment takes an integer input and uses if/elseif/else statements to display if the number is positive, negative, or zero. The second assignment takes a mark as input and uses if/elseif statements to display the corresponding grade. The third assignment counts the number of times the value 7 appears in a sample data array.

Uploaded by

Razee Syazwan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Assignment 1 Razee

The document contains 3 MATLAB assignments. The first assignment takes an integer input and uses if/elseif/else statements to display if the number is positive, negative, or zero. The second assignment takes a mark as input and uses if/elseif statements to display the corresponding grade. The third assignment counts the number of times the value 7 appears in a sample data array.

Uploaded by

Razee Syazwan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

ASSIGNMENT 1

Command clear all close all clc x = input('Enter an interger: '); if x>0 disp('You enter a positive interger'); end if x<0 disp('You enter a negative interger'); end if x==0 disp('Number you enter is zero'); end

Output Enter an interger: 1 You enter a positive interger

Enter an interger: -1 You enter a negative interger

Enter an interger: 0 Number you enter is zero

ASSINGMENT 2 Command
clear all close all clc x = input('Key in mark and view grade: '); if x>=0 & x<=39 disp('Grade F'); elseif x>=40 & x<=49 disp('Grade D'); elseif x>=50 & x<=59 disp('Grade C'); elseif x>=60 & x<=69 disp('Grade B'); elseif x>=70 & x<=100 disp('Grade A');

else disp('Input error'); end

Output

Key in mark and view grade: 35 Grade F

Key in mark and view grade: 45 Grade D

Key in mark and view grade: 55 Grade C

Key in mark and view grade: 65 Grade B

Key in mark and view grade: 75 Grade A

ASSIGNMENT 4
X=[ -2 4 7 -9 3 11 7 5 7 ] [i j]=size(X) count=0; for a=1:j if X(1,a)==7 count=count+1; end end count

Output

X=

-2

7 -9

3 11

i=

j=

count =

You might also like