0% found this document useful (0 votes)
51 views5 pages

Assignment Programming

The document contains 5 programming assignments in MATLAB: 1. Calculates the sum of elements in a list and prints the list. 2. Prompts the user to enter an outside temperature in Celsius or Fahrenheit and outputs appropriate clothing advice. 3. Takes a test score input between 0-100 and outputs the corresponding letter grade, using if/else statements and comparing ranges. 4. Plots the graph of an equation between x=0 to 35 on the x-axis and y=0 to 3.5 on the y-axis. 5. Plots the graphs of two equations, sinh(x) and 0.5*exp(x), on the same axes from x

Uploaded by

IzzatiHazwani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views5 pages

Assignment Programming

The document contains 5 programming assignments in MATLAB: 1. Calculates the sum of elements in a list and prints the list. 2. Prompts the user to enter an outside temperature in Celsius or Fahrenheit and outputs appropriate clothing advice. 3. Takes a test score input between 0-100 and outputs the corresponding letter grade, using if/else statements and comparing ranges. 4. Plots the graph of an equation between x=0 to 35 on the x-axis and y=0 to 3.5 on the y-axis. 5. Plots the graphs of two equations, sinh(x) and 0.5*exp(x), on the same axes from x

Uploaded by

IzzatiHazwani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

Assignment Programming

1. x=[45,23,17,34,85,29,13,89,100,101,79,80,99,1,5,6,7,3]
count=sum(x)
for k=1:length(x)
end
>> Untitled
x=
Columns 1 through 7
45

23

17

34

85

29

13

Columns 8 through 14
89 100 101 79 80 99
Columns 15 through 18
5

count =
816

2. Temperature=menu('You can decide the unit of temperature to


display','Celcius','Farenheit');
switch Temperature
case 1
x=input('Enter the scalar value for the outside air temperature
in Celcius:');
x=(x*9/5)+32
if x>=80 ;
disp('You need to wear shorts')
else if 60>x<80;
disp('It indeed a beutiful day')
else
disp('You are advised to wear jacket or something')
end
end
case 2
y=input('Enter the scalar value for the outside air temperature
is Farenheit:');
if y>=80;
disp('You need to wear shorts')
else if 60>y<80;
disp('It indeed a beutiful day')
else
disp('You are advised to wear jacket or something')
end
end
End
>> Untitled2
Enter the scalar value for the outside air temperature in Celcius:27
x=
80.6000
You need to wear shorts

3.a)x=input('Enter the value from 0 to 100:');


if x<=100&&x>0,
if x<=100&&x>=90,
disp('A')
end
if x<90&&x>=80;
disp('B')
end
if x<80&&x>=70;
disp('C')
end
if x<70&&x>60;
disp('D')
end
if x<60&&x>=0,
disp('F')
end
else
disp('input error')
End
>> Untitled3
Enter the value from 0 to 100:25
F

3.b)x=input('Enter the value from o to 100:');


if x<=100&&x>=90;
disp('A')
elseif x<90&&x>=80;
disp('B')
elseif x<80&&x>=70;
disp('C')
elseif x<70&&x>=60;
disp('D')
elseif x<60&&x>=0;
disp('F')
else
disp('Input error')
end
>> Untitled4
Enter the value from o to 100:87
B

4.x=[0:0.01:35];
y=0.4*sqrt(1.8.*x);
plot(x,y)
xlabel('x')
ylabel('y')
title('equation y')
axis([0 35 0 3.5])

5.x=[0:0.01:2];
y=sinh(x);
z=0.5.*exp(x);
plot(x,y,x,z),xlabel('x'),ylabel('y'),gtext('sinh(x)'),gtext('0.5*exp(x)')

You might also like