%modified 3-31-05 Tadd Truscott % Jason Dahl % Make Bretschneider plots for 13.42 Lab 3 % 5/5/03 %plots all the heave, pitch, and wave spectral densities from the bret %schneider wave run. clear all; name = input('What is the .asc bret schneider filename in directory: ','s'); nameu = input ('What is the .asc filename of the /n forward speed bret schneider in directory: ','s'); %input asci file into a matrix. rename columns. Columns are arranged for %this lab time, pitch, heave, upstream waveprobe, midship waveprobe. M=dlmread(name,'\t',8,0); time=M(:,1); heave_position=M(:,3); surface_height=M(:,5); %midships wave probe. pitch_angle=M(:,2); Mu=dlmread(nameu,'\t',8,0); time=Mu(:,1); uheave_position=Mu(:,3); usurface_height=Mu(:,5); %midships wave probe. upitch_angle=Mu(:,2); [P,F] = pwelch(surface_height,[],[],[],2*pi*250); [Pu,Fu] = pwelch(usurface_height,[],[],[],2*pi*250); %pmax=max(P); %normalize plot to scale of 0-1 %P=P./pmax; %pumax=max(Pu); %normalize plot to scale of 0-1 %Pu=Pu./pumax; figure(1); plot(F,P,Fu,Pu); title('Wave spectral Density plot'); xlabel('Frequency, rad/s'); ylabel('Wave Spectral Density'); legend('No-Forward Speed','Forward Speed'); axis([0 20 0 0.2]); [G,D] = pwelch(heave_position,[],[],[],2*pi*250); %gmax=max(G);%normalize plot to scale of 0-1 %G=G./gmax; [Gu,Du] = pwelch(uheave_position,[],[],[],2*pi*250); %gumax=max(Gu);%normalize plot to scale of 0-1 %Gu=Gu./gumax; figure(2); plot(D,G,Du,Gu); title('Heave Spectral Density plot'); xlabel('Frequency, rad/s'); ylabel('Heave Spectral Density'); legend('No-Forward Speed','Forward Speed'); axis([0 20 0 0.1]); [A,B] = pwelch(pitch_angle,[],[],[],2*pi*250); %amax=max(A);%normalize plot to scale of 0-1 %A=A./amax; [Au,Bu] = pwelch(upitch_angle,[],[],[],2*pi*250); %aumax=max(Au);%normalize plot to scale of 0-1 %Au=Au./aumax; figure(3); plot(B,A,Bu,Au); title('Pitch Spectral Density plot'); xlabel('Frequency, rad/s'); ylabel('Pitch Spectral Density'); legend('No-Forward Speed','Forward Speed'); axis([0 20 0 0.1]);