How to generate a 10-bit digital signal of given 10 digits?
2 次查看(过去 30 天)
显示 更早的评论
Given code:
Am=5; % Amplitude of modulating signal
fa=300; % Frequency of modulating signal
Ta=1/fa; % Time period of modulating signal
Ts=Ta/80; % Sampling interval
t=0:Ts:(10*Ta-Ts); % Total time for simulation
ym=Am*cos(2*pi*fa*t); % Equation of sinusoidal modulating signal
figure(1)
subplot(4,1,1);
plot(t,ym), grid on; % Graphical representation of input modulating signal
title ( ' Input Modulating Signal ');
xlabel ( ' Time (sec) ');
ylabel (' Amplitude (volt) ');
My Question:
1. How to modify the program code of the “Input modulating signal” (line 6) to
generate a 10 bit digital signal , which the 10 digits are "1234567890"
with each digit spans for a period of Ta .
(The resultant code will be assigned to the variable ym.)
2. How to use the MATLAB functions ones(1,n) to generate your resultant
code?
3. What is the required number of repetitions for each digit in terms of Ta (digit period) and Ts (sampling period). The amplitude of each bit will be corresponding to the value of the respective
digital (123467890).
Thank you for answering my questions and showing me the new code for ym. ^_^
0 个评论
采纳的回答
Kevin Barkett
2021-2-12
Hi there,
If I'm understanding your question correctly, what you are attempting to do is create an array for the variable which returns something like 'ym = [ 1 1 ... 1 1 2 2 ... 2 2 3 3 ....... 0 0 ];'
One way you create that from the variables you've defined above is:
ym = mod(floor(t/Ta)+1,10);
By using 'floor(t/Ta)', this creates an array of numbers partitioned between intervals evenly spaced by the period 'Ta' with each element in a partition numbered according to which period it occurs in. The rest of the function is to shift the array to the desired values for each interval. Since computing 'ym' in this way sets it with the same array extents as 't', I am unsure why it is necessary to use the 'ones(1,n)' function.
Using the definition given for 'Ta' and 'Ts', the number of elements in the array across each interval of 'Ta' (and thus the number of repetitions of each digit) can be obtained
numberOfSamples = Ta/Ts;
since that corresponds to how many distinct sampling intervals occur over the entire period.
Cheers,
Kevin
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!