Matlab+Lab1++Solutions

Matlab+Lab1++Solutions - %-Period = ? plot( tt4, xx4)...

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

View Full Document Right Arrow Icon
Matlab Solutions: 4.2.1: Function: syn_sin function [xx,tt] = syn_sin(fk, Xk, fs, dur, tstart) %SYN_SIN Function to synthesize a sum of cosine waves % usage: % [xx,tt] = syn_sin(fk, Xk, fs, dur, tstart) % fk = vector of frequencies % (these could be negative or positive) % Xk = vector of complex amplitudes: Amp*eˆ(j*phase) % fs = the number of samples per second for the time axis % dur = total time duration of the signal % tstart = starting time (default is zero, if you make this input optional) % xx = vector of sinusoidal values % tt = vector of times, for the time axis % % Note: fk and Xk must be the same length. % Xk(1) corresponds to frequency fk(1), % Xk(2) corresponds to frequency fk(2), etc. n=length(fk); xx=0; tt = tstart:1/fs:dur; for k=1:n xx=xx+real(Xk(k)*exp(1i*2*pi*fk(k)*tt)); end Tesing: [xx4,tt4] = syn_sin([0,100,250], [10,14*exp(-j*pi/3),8*j], 10000, 0.1,0);
Background image of page 1

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

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

Unformatted text preview: %-Period = ? plot( tt4, xx4) Period : .02 Frequency: 50 5: Testing code: [xx4,tt4] = syn_sin([.5,.5,.5,.5], [2,2*exp(-j*pi*1.25),1,-j], 2000, 6,-.5); plot(tt4,xx4); 6: %--%--- multipath for Lab #2 %--c = 3e8; xv = 0:0.1:300; %-- vehicle locations in meters dt = 1500; %-- location of the transmitter dr = [100,900]; %-- location of the reflector G_r = 1; %-- gain of the reflector phi_r = pi; %-- phase of the reflector fo = 150e6; %-- in Hz lambda = c/fo % Rtv = abs(xv+j*dt); %-- range between xmtr and vehicle zr = dr*[1;j]; Rrefv = abs(xv-zr) + abs(j*dt-zr); %-- range between xmtr, refl and veh % delay_1 = Rtv/c; delay_2 = Rrefv/c; % X_1 = exp(-j*2*pi*fo*delay_1); X_2 = G_r*exp(j*phi_r)*exp(-j*2*pi*fo*delay_2); X_v = X_1 + X_2; % plot( xv, abs(X_v) ) shg...
View Full Document

This note was uploaded on 01/03/2012 for the course EEL 3135 taught by Professor ? during the Fall '08 term at University of Florida.

Page1 / 3

Matlab+Lab1++Solutions - %-Period = ? plot( tt4, xx4)...

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

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