Anyone please explain this program in detail. This program is to generate sine and cosine coefficients to be used in Simulation.

2 views (last 30 days)
clc; clear; disp('Enter the Carrier Crequeincy in MHz'); Fc = input('Carrier_Frequency ='); Fc = Fc*10^6; if isempty(Fc) Fc = 10*10^6; end disp('Enter the Number of Sample in one period'); N = input('Number of Sample ='); if isempty(N) N = 16; end disp('Enter the Number of bit to represent sine and cosine wave'); num_of_bits = input('Number of bits ='); if isempty(num_of_bits) num_of_bits = 8; end Tc = 1/Fc; Fs = Fc*N; Ts = 1/Fs; i = 1; for t = 0 : Ts : Tc-Ts I(i) = sin(2*3.14*Fc*t); Q(i) = cos(2*3.14*Fc*t); i = i+1; end I1 = I*2^(num_of_bits-1) Q1 = Q*2^(num_of_bits-1) I2 = fi(I1,true,num_of_bits,0) Q2 = fi(Q1,true,num_of_bits,0) I2_hex = I2.hex Q2_hex = Q2.hex I2_bin = I2.bin Q2_bin = Q2.bin
% I2 = int32(I1); % Q2 = int32(Q1); % I3 = num2hex(I1); % Q3 = num2hex(Q1);
  1 Comment
John D'Errico
John D'Errico on 14 Mar 2015
Edited: John D'Errico on 14 Mar 2015
Next, learn how to format the code you paste in to be readable. As you can see, what shows here is an unreadable mess. If you expect help, how will anyone read this?
Finally, if you need detailed explanations for a long but theoretically simple piece of code, you need to READ THE BASIC TUTORIALS IN MATLAB. You got the code from someone. So ask them for an explanation. They know what it does since they wrote it.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!