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');

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education