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

clear all

clc
fprintf('CE 491 HW 2 Problem 4.\n')
fprintf('Press Enter to start.')
prompt1='';
start=input(prompt1);
fprintf('\nEnter the number of slopes ')
fprintf('up to or including 200-m depth: ')
prompt2='';
no_of_slopes=input(prompt2);
if no_of_slopes==1
fprintf('What is the slope? ')
prompt3='';
S=input(prompt3);
x=200/S;
X=x/1000;
fprintf('Continental shelf width is ')
fprintf('%i meters or %3.3f kilometers.\n',x,X)
break;
else
for i=1:no_of_slopes
fprintf('Slope_%i = ',i)
prompt4='';
slope(i)=input(prompt4);
end
for j=1:(no_of_slopes-1)
fprintf('Max depth within Slope_%i in meters: ',j)
prompt5='';
depth(j)=input(prompt5);
end
for k=2:(no_of_slopes-1)
for l=1:(k-1)
depth(k)=depth(k)-depth(l);
end
end
x=200/slope(no_of_slopes);
for m=1:(no_of_slopes-1)
x=x-depth(m)/slope(no_of_slopes)+depth(m)/slope(m);
end
X=x/1000;
fprintf('Continental shelf width is ')
fprintf('%i meters or %3.3f kilometers.\n',x,X)
end

You might also like