You are on page 1of 5

%Jeriah Jordan

%10/25/21
%CS 1972, Program 6

disp('Problem1')
printspherical(3,6,3)

disp('Problem2')
num2

disp('Problem3')
num3c

disp('Problem4')
num4

disp('Problem5')
messagestring1='The Early sonGbird tweetS';
m=cryptmessage(messagestring1);
m

disp('Problem6')
wordscramble('Hello')
wordscramble('elephant')

disp('Problem7')
num7

printspherical
function printspherical(x,y,z)
[r,theta,phi]=convert2spher(x,y,z);
fprintf('The radius is %f\n',r);
fprintf('The inclination angle is %f\n',theta);
fprintf('The azimuth angle is %f\n',phi);
end

convert2spher
function [r,theta,phi]=convert2spher(x,y,z)
r=(x^2+y^2+z^2).^0.5;
theta=acos(z/r);
phi=atan(y/x);
end
num2
x1=input('Enter x1\n');
y1=input('Enter y1\n');
x2=input('Enter x2\n');
y2=input('Enter y2\n');
x3=input('Enter x3\n');
y3=input('Enter y3\n');
fprintf("The area of Triangle is %f\n",areat(x1,x2,x3,y1,y2,y3));

function d=distance(x1,y1,x2,y2)
d=((x2-x1)^2+(y2-y1)^2)^(0.5);
end

function area=areat(x1,x2,x3,y1,y2,y3)
a=distance(x1,y1,x2,y2);
b=distance(x2,y2,x3,y3);
c=distance(x1,y1,x3,y3);
s=(a+b+c)/2;
area=(s*(s-a)*(s-b)*(s-c))^0.5;
end

position
function [x,y]=position(v,t,angle)
x=v*cosd(angle)*t;
y=v*sind(angle)*t-(1/2*9.81*t^2);
end

printresult
function printresult(x,y)
fprintf('The x coordinates are %d\n',x);
fprintf('The y coordinates are %d\n',y);
end
num3c
initialvelocity=25000;
time=65;
angle=40;
[x,y]=position(initialvelocity,time,angle);
printresult(x,y)

num4
r=randi([10 80],3,1);
s=strcat(int2str(r(1)),int2str(r(2)),int2str(r(3)));
answer=char(s)

cryptmessage
function m=cryptmessage(str)
m="";
strLen=length(str);
while(strLen>0)
[word,str]=strtok(str);
strLen=length(str);
m=strcat(m,upper(word(1)));
end
end

wordscramble
function wordscramble(str)
str=str(randperm(length(str)));
disp(str)
end
num7
load avghighs.txt
[rows,cols]=size(avghighs);
for i=1:rows
location=avghighs(i,1);
temps=avghighs(i,2:13);
subplot(1,3,i)
plot(1:12,temps, 'bo' )
title(sprintf( 'Location %d',location))
xlabel( 'Month' )
ylabel( 'Avg High Temps' )
mintemp=min(min(avghighs(1:3,2:13)));
maxtemp=max(max(avghighs(1:3,2:13)));
axis([1 12 mintemp maxtemp])
end

output

Program6

Problem1

The radius is 7.348469

The inclination angle is 1.150262

The azimuth angle is 1.107149

Problem2

Enter x1

Enter y1

Enter x2

Enter y2

26

Enter x3
54

Enter y3

20

The area of Triangle is 504.000000

Problem3

The x coordinates are 1.244822e+06

The y coordinates are 1.023806e+06

Problem4

answer =

'632958'

Problem5

m=

"TEST"

Problem6

lelHo

ehealnpt

Problem7

You might also like