How to plot temporal representations?

조회 수: 11 (최근 30일)
IsTun
IsTun 2019년 5월 12일
답변: Vidhi Agarwal 2024년 9월 27일
Hello everybody, i hope you and everyone here can help me in plotting temporal representations of x1(t), x21(t), x22(t) and x23(t)
This code :
N = 1e3; % Number of data points
T0 = pi; % Can be any number
t = linspace(0, T0, N); % time space with N data points
f0=1000; f1=2000; f2=2000;
x1 = sin(2*pi*f0*t)+sin(2*pi*f1*t)+sin(2*pi*f2*t);
T1 =2*pi; % Can be any number
t1 = linspace(0, T1-pi/N, N); % time space with N data points
x21 = sin(2*pi*f0*t1);
T2 = 3*pi; % Can be any number
t2 = linspace(T1, T2-pi/N, N); % time space with N data points
x22 = sin(2*pi*f1*t2);
T3 = inf;
t2 = linspace(T2, T3, N);
x23 = sin(2*pi*f2*t2);

답변 (1개)

Vidhi Agarwal
Vidhi Agarwal 2024년 9월 27일
After resolving some issues with given code, using “plot” function of MATLAB, you can plot the temporal representations of (x_1(t)), (x_{21}(t)), (x_{22}(t)), and (x_{23}(t)).
  • Try setting “T3” to finite range so that it’s easy to plot the same.
T3 = 4*pi; % Arbitrary finite endpoint for x23
  • Avoid overwriting “t2” with new range and use a different variable name for third time range.
t3 = linspace(T2, T3-pi/N, N); % Time vector for x23
  • Ensure that all time ranges are consistent and make sense within the context of your problem.
The plot after resolving the issues will look like given below:
For better understanding of “plot” function refer to the following documentation:
Hope that helps!

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by