Sameen Yusuf BENG 301: Homework #1 February 3, 2016 1. Assume an ADC with 12-bits and a maximum input voltage range of ± 2.5V. a. What is the smallest discernible voltage difference for the converter? That is, what is the voltage/level for the converter? • For 12-bit ADC, 212 = 2096 levels (0 to 4095 or -2047 to 2048) • 5.0 V range/4096 levels = 0.122 mV/level b. If you wanted the output voltage/level of the ADC to be at least 1 microvolt/level, how much would you need to amplify the signal prior to passing it to the ADC? • 1 mV/level = (0.122 mV/level)/x, where x is the minimum gain. x = 122 • I must amplify the signal by a factor of 122 before passing it to the ADC 2. You are given an ADC with a maximum range of +/- 2V. Choose appropriate number of bits (either 8, 10, or 12) and gain (either 500, 1000, 2000, 4000, or 8000) for measuring biopotentials with a resolution of 1 µV/level. Note that maximum amplitude of the biopotential will not exceed +/- 1 mV. • Maximum gain = maximum range/ biopotential maximum range = 4V/(0.002 V) = 2000 o Chosen gain = 2000 • Desired referred resolution of 1 µV/level: o Referred resolution * gain = 1 µV/level * 2000 = 2 mV/level at ADC input desired o 4 V/ 2n = 2 mV/level, 2n = 2000, log2 (2000) = 10.97 o Number of bits chosen = 12 • Chosen gain: 2000, chosen number of bits: 12.
3. For time ranging from 0 to 10 seconds, a voltage function is defined as V(t) = 0.5*t-2.5. An 4-bit ADC is used to sample this voltage every 0.1 s. Using MATLAB, show a plot of V(t) and overlay the plot of digitized measurement.
In another plot, repeat for an 8-bit digitizer. Now, produce both the 4-bit and 8-bit plots for V = 2.5*sin(2*pi*t*0.25). You should have a total of four plots. Adjust the Y-ticks in the 4-bit plots to show the values corresponding to ADC levels.
4. You are building an instrument for recording voltage signals with maximum amplitude of +/-1V. The bandwidth of the signal is expected to be between 10kHz to 1 MHz. Research online and find spec sheets for filter(s) and an amplifier to achieve the desired bandwidth with a gain of 10. • See attached documents. 5. The data collected from class has been loaded into class_bio_data.mat file. Using this data, a. test the hypothesis that men’s height is different from women’s height, H0: No difference in men and women’s height H1: There is a difference in men and women’s height t-critical value for height: -6.0013. H1 is true – there is a difference between their heights
b. test the hypothesis that men’s shoe size is different from women’s shoe size, and H0: No difference in men and women’s shoe sizes H1: There is a difference in men and women’s shoe sizes t-critical value for shoe size: -0.4957. H1 there is a difference in men and women’s sizes
c. Check if there is a linear correlation between shoe size and height for the entire population. Plot the scatter data and the fit, and calculate the correlation coefficient. correlation coefficient = 0.8646
%Problem 5, Part A %Create separate lists of male and female data sets %Count the number of each gender countf = 0;countm = 0; for k = 1:length(BioStats.Gender) if BioStats.Gender(k) == 'f' countf = countf+1; else countm = countm+1; end end %Establish the vector sizes Female_Height = zeros(countf, 1); Male_Height = zeros(countm, 1); Female_Shoe = zeros(countf, 1);Male_Shoe = zeros(countm,1); %Keep note of indexes in the separated vectors findex = 1; mindex = 1; %Separate the datasets for k = 1:length(BioStats.Gender) if BioStats.Gender(k) == 'f' Female_Height(findex) = BioStats.Height(k); Female_Shoe(findex) = BioStats.Shoe_size(k); findex = findex+1; else Male_Height(mindex) = BioStats.Height(k); Male_Shoe(mindex) = BioStats.Shoe_size(k); mindex = mindex+1; end end %Create histogram of the two separate genders to see overlay %Height Histogram figure; hist(Female_Height); h = findobj(gca, 'Type', 'patch'); set(h, 'FaceColor', 'r', 'EdgeColor', 'w', 'facealpha', 0.75); hold on; hist(Male_Height); xlabel('Height (in)'); ylabel('Frequency'); title('BENG 301 Spring 2016 Height Distribution'); legend('Female', 'Male'); %Height t-test calculation FHstd = std(Female_Height); MHstd = std(Male_Height); SEH = sqrt( (FHstd^2/countf) + (MHstd^2/countm)); FHMean = mean(Female_Height); MHMean = mean(Male_Height); tH = (FHMean-MHMean)/SEH; disp('t critical value for height'); disp(tH);
%Problem 5, Part B %Shoe Size Histogram figure; hist(Female_Shoe); h = findobj(gca, 'Type', 'patch'); set(h, 'FaceColor', 'r', 'EdgeColor', 'w', 'facealpha', 0.75); hold on; hist(Male_Shoe); xlabel('Shoe Size'); ylabel('Frequency'); ylabel('Frequency'); title('BENG 301 Spring 2016 Shoe Size Distribution'); legend('Female', 'Male'); %Shoe Size t-test calculation FSstd = std(Female_Shoe); MSstd = std(Female_Shoe); SES = sqrt((FSMean^2/countf) + (MSstd^2/countf)); FSMean = mean(Female_Shoe); MSMean = mean(Male_Shoe); tS = (FSMean-MSMean)/SES; disp('t critical value for shoe size'); disp(tS); %Problem 5, Part C %Scatter plot and linear plot modfun = @(m,x)(m.*x); y = nlinfit(BioStats.Shoe_size, BioStats.Height, modfun, 1); Fit = y.*BioStats.Shoe_size figure; plot(BioStats.Shoe_size, Fit) hold on; scatter(BioStats.Shoe_size, BioStats.Height) xlabel('Shoe Size'); ylabel('Height (in)'); %Correlation factor calculation
r = corr2(BioStats.Shoe_size, BioStats.Height); disp('correlation factor'); disp(r); %Problem 3 %established variables t = [0:0.1:10]; Vt = 0.5*t - 2.5 %found the range for quantization Vmin=min(Vt(:)); Vmax=max(Vt(:)); %number of samples is dependent on the number of bits N=2^4; %establish delta step delta=(Vmax-Vmin)/N; y=[Vmin+delta/2:delta: Vmax]; %declare new time variable using the maximum and minimum range t= [min(Vt(:))-1 (y(1:N-1)+y(2:N))/2 max(Vt(:))+1]; Vq4=zeros(size(Vt)); %step through and calculate the quantized values for i=1:N,Vq4=Vq4+((t(i)<=Vt)&(Vt<t(i+1)))*y(i); end %plot t = linspace(0, 10, length(Vt)); figure; plot(t, Vt, 'r'); hold on; plot(t, Vq4, 'b'); xlabel('time (sec)'); ylabel('V(t)'); title('V(t) sampled, 8 bits'); legend('V(t)', 'V(t), 4 bits'); % same process as before, but 8 bits for linear V(t) N=2^8; delta=(Vmax-Vmin)/N; y=[Vmin+delta/2:delta: Vmax]; t= [min(Vt(:))-1 (y(1:N-1)+y(2:N))/2 max(Vt(:))+1]; Vq8=zeros(size(Vt)); for i=1:N, Vq8=Vq8+((t(i)<=Vt)&(Vt<t(i+1)))*y(i);end t = linspace(0, 10, length(Vt)); figure;plot(t, Vq8); xlabel('time (s)'); ylabel('V(t) 8 bits'); title('V(t) sampled, 8 bits'); % same process as before, but change V to sine function t = [0:0.1:10]; V = 2.5*sin(2*pi*t*0.25); xmin=min(V(:)); xmax=max(V(:)); N=2^8; delta=(xmax-xmin)/N; y=[xmin+delta/2:delta: xmax]; t= [min(V(:))-1 (y(1:N-1)+y(2:N))/2 max(V(:))+1]; Vq8=zeros(size(V)); for i=1:N, Vq8=Vq8+((t(i)<=V)&(V<t(i+1)))*y(i); end t = [0:0.1:10]; N=2^4; delta=(xmax-xmin)/N; y=[xmin+delta/2:delta: xmax]; t= [min(V(:))-1 (y(1:N-1)+y(2:N))/2 max(V(:))+1]; Vq4=zeros(size(V)); for i=1:N,Vq4=Vq4+((t(i)<=V)&(V<t(i+1)))*y(i); end t = linspace(0, 10, length(V)); figure;plot(t, Vq8); xlabel('time (s)'); ylabel('V(t) 8 bits'); title('V(t) sampled, 8 bits');
t = linspace(0, 10, length(V)); figure;plot(t, Vq4); xlabel('time (s)'); ylabel('V(t) = sin 4 bits'); title('V(t) = sin sampled, 4 bits');