What this "t=0:0.0001:0.1;" statement represent and how this syntax work in the given program?

조회 수: 50 (최근 30일)
%FM generation
clc;
clear all;
close all;
fc=input('Enter the carrier signal freq in hz,fc=');
fm=input('Enter the modulating signal freq in hz,fm =');
m=input('Modulation index,m= ');
t=0:0.0001:0.1;
c=cos(2*pi*fc*t);%carrier signal
M=sin(2*pi*fm*t);% modulating signal
subplot(3,1,1);plot(t,c);
ylabel('amplitude');xlabel('time index');title('Carrier signal');
subplot(3,1,2);plot(t,M);
ylabel('amplitude');xlabel('time index');title('Modulating signal');
y=cos(2*pi*fc*t-(m.*cos(2*pi*fm*t)));
subplot(3,1,3);plot(t,y);
ylabel('amplitude');xlabel('time index');title('Frequency Modulated signal');
fs=10000;
p=fmdemod(y,fc,fs,(fc-fm));
figure;
subplot(1,1,1);plot(p);

답변 (2개)

KSSV
KSSV 2019년 2월 26일
편집: KSSV 2019년 2월 26일
t=0:0.0001:0.1
The above line generates an array with first element as 0 and last element as 0.1, where each sucessive elements have a common difference of 0.0001. It is a Arithmetic preogression.

Idin Motedayen-Aval
Idin Motedayen-Aval 2025년 5월 6일
It is creating a time vector that is used in the next two lines to generate the sine and cosine functions, and then in plotting those functions. As the previous answer said: start at time 0, go up to 0.1, in steps on 0.0001.
Another way to think of it: it's time vector with a sampling time of 0.0001s (0.1ms), or a sampling frequency of 10kHz. This corresponds to "fs = 10000;" near the end of the program.
  댓글 수: 1
Walter Roberson
Walter Roberson 2025년 5월 6일
편집: Walter Roberson 2025년 5월 6일
Quibble:
time vector with a sampling time of 0.0001 could imply that the vector is like (0:1000)*0.0001 -- time 0/10000, 1/10000, 2/10000 and so on .
But that is not actually the case. The actual vector is 0, 0+0.0001, 0+0.0001+0.0001, 0+0.0001+0.0001+0.0001, and so on
actual = 0:0.0001:0.1;
nominal = (0:1000)*0.0001;
mismatches = find(actual~=nominal);
format long g
am5 = actual(mismatches(1:5))
am5 = 1×5
0.0506 0.0511 0.0523 0.0528 0.054
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
nm5 = nominal(mismatches(1:5))
nm5 = 1×5
0.0506 0.0511 0.0523 0.0528 0.054
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
am5-nm5
ans = 1×5
1.0e+00 * 6.93889390390723e-18 6.93889390390723e-18 6.93889390390723e-18 6.93889390390723e-18 6.93889390390723e-18
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
The actual vector has accumulated floating point round-off; the nominal vector does not have accumulated floating point round-off
@KSSV's description of arithmetic progression was correct; describing it in terms of sampling times is not completely accurate.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by