clc clear close all % Problem 2-19 % Text Book(s): Electronic Communications: Principles and Systems % Calculating the coefficients equations A_0, A_n and B_n syms t n; A = 0.004; T = 0.01; f1 = 1/T; w=2*pi*f1; A_0 = 0; A_n = (2/T)*(((int(t*cos(w*n*t),t,0,0.004)))+((int((-4*t+0.020)*cos(w*n*t),t,0.004,0.005)))+((int((-1*t+0.005)*cos(w*n*t),t,0.005,0.009)))+((int((4*t-0.04)*cos(w*n*t),t,0.009,0.01)))); B_n = (2/T)*(((int(t*sin(w*n*t),t,0,0.004)))+((int((-4*t+0.020)*sin(w*n*t),t,0.004,0.005)))+((int((-1*t+0.005)*sin(w*n*t),t,0.005,0.009)))+((int((4*t-0.04)*sin(w*n*t),t,0.009,0.01)))); %% % Calculating the series coefficients n = 1:N N = 50; for n = 1 : N An(n) = eval(A_n); Bn(n) = eval(B_n); end subplot(4,1,1); stem(1:N,An); hold;grid; stem(1:N,Bn,'r'); stem(0,A_0,'c');hold off % The Fourier Series % for n = 1 : N Fun(n) = An(n)*cos((w*n)*t)+Bn(n)*sin((w*n)*t); end FunS = A_0 + sum(Fun); t = -2*T : T/100 : 2*T; subplot(4,1,2); plot(t,eval(FunS)); grid %Attempt at Fourier transform y=fft(eval(FunS)); subplot(4,1,3); plot(t,y); grid subplot(4,1,4); plot(t,real(y),t,imag(y)); grid % Define the number of quantization levels (bits) N_bits = 8; % You can adjust this value to your needs % Calculate the range for each quantization level max_value = max(eval(FunS)); min_value = min(eval(FunS)); range = max_value - min_value; % Calculate the step size step_size = range*2 / (2^N_bits); % Quantize the signal quantized_signal = round((FunS - min_value) / step_size) * step_size + min_value; % Plot the quantized signal figure; subplot(2,1,1); stem(t, eval(quantized_signal)); xlim([-0.01, 0.01]); grid; title('Quantized Signal'); % Plot the original signal for comparison subplot(2,1,2); plot(t, eval(FunS)); xlim([-0.01, 0.01]); grid; title('Original Signal');

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter3: Assignment, Formatting, And Interactive Input
Section3.3: Using Mathematical Library Functions
Problem 8E: (Transportation) Road construction requires estimating the expected loads on a road’s pavement over...
icon
Related questions
Question

clc clear close all % Problem 2-19 % Text Book(s): Electronic Communications: Principles and Systems % Calculating the coefficients equations A_0, A_n and B_n syms t n; A = 0.004; T = 0.01; f1 = 1/T; w=2*pi*f1; A_0 = 0; A_n = (2/T)*(((int(t*cos(w*n*t),t,0,0.004)))+((int((-4*t+0.020)*cos(w*n*t),t,0.004,0.005)))+((int((-1*t+0.005)*cos(w*n*t),t,0.005,0.009)))+((int((4*t-0.04)*cos(w*n*t),t,0.009,0.01)))); B_n = (2/T)*(((int(t*sin(w*n*t),t,0,0.004)))+((int((-4*t+0.020)*sin(w*n*t),t,0.004,0.005)))+((int((-1*t+0.005)*sin(w*n*t),t,0.005,0.009)))+((int((4*t-0.04)*sin(w*n*t),t,0.009,0.01)))); %% % Calculating the series coefficients n = 1:N N = 50; for n = 1 : N An(n) = eval(A_n); Bn(n) = eval(B_n); end subplot(4,1,1); stem(1:N,An); hold;grid; stem(1:N,Bn,'r'); stem(0,A_0,'c');hold off % The Fourier Series % for n = 1 : N Fun(n) = An(n)*cos((w*n)*t)+Bn(n)*sin((w*n)*t); end FunS = A_0 + sum(Fun); t = -2*T : T/100 : 2*T; subplot(4,1,2); plot(t,eval(FunS)); grid %Attempt at Fourier transform y=fft(eval(FunS)); subplot(4,1,3); plot(t,y); grid subplot(4,1,4); plot(t,real(y),t,imag(y)); grid % Define the number of quantization levels (bits) N_bits = 8; % You can adjust this value to your needs % Calculate the range for each quantization level max_value = max(eval(FunS)); min_value = min(eval(FunS)); range = max_value - min_value; % Calculate the step size step_size = range*2 / (2^N_bits); % Quantize the signal quantized_signal = round((FunS - min_value) / step_size) * step_size + min_value; % Plot the quantized signal figure; subplot(2,1,1); stem(t, eval(quantized_signal)); xlim([-0.01, 0.01]); grid; title('Quantized Signal'); % Plot the original signal for comparison subplot(2,1,2); plot(t, eval(FunS)); xlim([-0.01, 0.01]); grid; title('Original Signal');

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 6 images

Blurred answer
Knowledge Booster
Time complexity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr