function dZ=undervatten(x,Z) p=[5.8796 14.4874 257.1923]; c=@(z) 4800+p(1)+(p(2)*z/1000)+(p(3)*exp(-z/1000)); c0=c(2000); dZ=zeros(2,1); dZ(1)=Z(2); dZ(2)=-(c0/cosd(7.8))^2*(((-p(3)/1000)*exp(-Z(1)/1000))+p(2)/1000)/... (4800+p(1)+p(2)*Z(1)/1000+p(3)*exp(-Z(1)/1000))^3; end
This is my function using the information from the assignment and I have confirmed that it is correct. The value cosd(7.8) comes from the starting angle 7.8 degrees. I am then calling this function like this:
clear all, close all, clc
x=0:0.5:6076*25; n=7.8; [X,Z]=ode45(@undervatten,x,[2000 tand(n)]); plot(X,Z(:,1),'-r') xlabel('distance') ylabel('depth') axis ij
What about
x=0:0.5:6076*25; n=-10; for i=1:25 [X,Z]=ode45(@(x,z)undervatten(x,z,n),x,[2000 tand(n)]); Z_array(:,i)=Z(:,1); n=n+1; end plot(x,Z_array) function dZ=undervatten(x,Z,n) p=[5.8796 14.4874 257.1923]; c=@(z) 4800+p(1)+(p(2)*z/1000)+(p(3)*exp(-z/1000)); c0=c(2000); dZ=zeros(2,1); dZ(1)=Z(2); dZ(2)=-(c0/cosd(n))^2*(((-p(3)/1000)*exp(-Z(1)/1000))+p(2)/1000)/... (4800+p(1)+p(2)*Z(1)/1000+p(3)*exp(-Z(1)/1000))^3; end
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.