Wave finder

Wave finder - Newton Raphson...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Appendix Wave finder function [waveperiod] = lab3( ); w=.01*load('wavedata.dat'); q=w(926:length(w)); h=0.234; dlt=0.04; j=1; %Zero up-crossing for i=1:length(q) - 1; if q(i)*q(i+1)<=0 & q(i+1)>=q(i); up1(j)=i; upu(j)=i+1; j=j+1; end end av=(up1+upu)/2; k=1; for i=1:length(av)-1; diff(k)=av(i+1)-av(i); k=k+1; end waveperiods=diff.*dlt length(waveperiods) for i=1:1:length(waveperiods) wavelength(i)=(2*pi)/(newtraph(waveperiods(i),.234,.001,500)) wave(i)=i end plot(wave,wavelength) xlabel('Waves') ylabel('Wavelength in meters') title('Wave length vs. Wave')
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Newton Raphson function [rt]=newtraph(t,h,es,maxit) g=9.81; w=2*pi/t syms x func=inline(w^2-g*x*tanh (x*h)) dfunc=inline(-9*tanh(x*h)+h*((sech(x*h))^2)*(-g*x)) k=(w^2)/(g*sqrt((w^2*h)/g)) if nargin<3,error('at least 3 input arguments required'),end if nargin<4|isempty(es),es=0.0001;end if nargin<5|isempty(maxit),maxit=50;end iter = 0; while (1) xrold = k; k = k - func(k)/dfunc(k); iter = iter + 1; if k ~= 0, ea = abs((k-xrold)/k)*100;end if ea <=es | iter>= maxit, break, end end rt = k;...
View Full Document

{[ snackBarMessage ]}

Page1 / 2

Wave finder - Newton Raphson...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online