Sunteți pe pagina 1din 15

Khue Tran ECE 5673 SP#1 Signal Processing Assignment #1 1. 2.

Here is the modified code: clear all; samptime=1/100; freq=20; for ii=1:100 time(ii)=(ii-1)*samptime; x(ii)=cos(2*pi*freq*time(ii)); end subplot(2,1,1); plot(time,x); title('Sampled Sinusoid with Sampling Rate of 100 Hz'); xlabel('Time (sec)'); ylabel('x(t)'); grid on; clear all; samptime=1/20; freq=20; time=[0:99]*samptime; x=cos(2*pi*freq*time); subplot(2,1,2); plot(time,x); title('Sampled Sinusoid with Sampling Rate of 20 Hz'); xlabel('Time (sec)'); ylabel('x(t)'); grid on; Figure created by the code:

We can see that the 100 Hz sampling rate (larger than twice the frequency of the wave 20Hz) is enough to describe the sine wave without aliasing. Whereas the sampling rate of 20Hz that is equal the frequency of the wave is inadequate. We sample the point with the same phase that when plot by matlab it will show a straight line. 3. Matlab code: [x,y]=meshgrid(-2:0.01:2); f=sin(2*x+3*y); figure(1); mesh(x,y,f); xlabel('X axis'); ylabel('Y axis'); zlabel('Z=sin(2X+3Y)'); figure(2); contour(x,y,f); xlabel('X axis'); ylabel('Y axis'); figure(3); contourf(x,y,f); xlabel('X axis'); ylabel('Y axis'); The three commands display the z value differently, for the mesh command, the graph of the function is display clearly visually but not all of the value of the function can be observed through the figure. Whereas the contour command though don't help user visualize the function easily it does show all the value of the function with relative to other through color. Its drawback is we cannot approximate the value of the function at each point directly but only through color code. For the contourf, the command fill all the

value of z with color according to its numerical value, it is more detail than the contour function Mesh:

Contour:

Contourf:

4. Figure: Real(v) vs t:

Imagine(v) vs t:

Real(v) vs Imagine (v):

Those figures do make sense because the signal v is corrupted by random noise generate by the command rand in both real and imaginary part but the overall signal can still be recognized as sinusoidal signal. 5. Here is the code: % % Program to read/plot sounding and calculate refractivity % clear all; % % load data and put into vectors %---------------------------------------------------------------------------% PRES HGHT TEMP DWPT RELH MIXR DRCT SKNT THTA THTE THTV % hPa m C C % g/kg deg knot K K K %---------------------------------------------------------------------------% sounding; press=data(:,1); alt=data(:,2)/1000; temp=data(:,3); td=data(:,4); rh=data(:,5); mixr=data(:,6);

direc=data(:,7); speed=data(:,8); thta=data(:,9); thte=data(:,10); thtv=data(:,11); % % calculate mixing ratio and refractivity % N: refractivity % Ndry: refractivity w/o water vapor % Nref: model refractivity (fig 2.7) % mixr=mixr/1000; pw=press.*(mixr./(0.622+mixr)); N=(77.6./(temp+273)).*(press+4810*(pw./(temp+273))); Ndry=(77.6./(temp+273)).*(press); Nref=313*exp(-0.1439*alt); figure(1); plot(press,alt); title('Pressure vs Height'); xlabel('Pres(hPa)'); ylabel('Height(km)'); figure(2); plot(temp,alt); title('Temperature vs Height'); xlabel('Temp(C)'); ylabel('Height(km)'); figure(3); plot(td,alt); title('Dew Point vs Height'); xlabel('DWPT(C)'); ylabel('Height(km)'); figure(4); plot(rh,alt); title('RELH vs Height'); xlabel('RELH(%)'); ylabel('Height(km)'); figure(5); plot(mixr,alt); title('Mixing Ratio vs Height'); xlabel('MIXR(g/kg)'); ylabel('Height(km)');

figure(6); plot(direc,alt); title('Direction vs Height'); xlabel('DRCT(deg)'); ylabel('Height(km)'); figure(7); plot(speed,alt); title('SKNT vs Height'); xlabel('SKNT(knot)'); ylabel('Height(km)'); figure(8); plot(thta,alt); title('THTA vs Height'); xlabel('THTA(K)'); ylabel('Height(km)'); figure(9); plot(thte,alt); title('THTE vs Height'); xlabel('THTE(K)'); ylabel('Height(km)'); figure(10); plot(thtv,alt); title('THTV vs Height'); xlabel('THTV(K)'); ylabel('Height(km)'); figure(11); plot(alt,N,alt,Nref); title('Refractivity with water vapor vs Height'); xlabel('Refractivity (N)'); ylabel('Height(km)'); legend('4/3 Earth Model', 'Reference Atmosphere'); figure(12); plot(alt,Ndry,alt,Nref); title('Refractivity without water vapor vs Height'); xlabel('Refractivity (N)'); ylabel('Height(km)'); legend('4/3 Earth Model', 'Reference Atmosphere'); hmax=10; % max height for fitting eradius=6374; % earth radius

fitparam=polyfit(alt(1:hmax),N(1:hmax),1); Nfit=fitparam(1)*alt+fitparam(2); dNdh=fitparam(1); refracgrad=dNdh*10^(-6); ae=1/((1/eradius)+(refracgrad)); The data used is from 43346 Karaikal Observations at 00Z 16 Sep 2011 The refractive index gradient calculated from the polyfit command is: -88.9575 The resulting effective radius is 16424 km.

S-ar putea să vă placă și