How to plot temporal representations?

9 visualizzazioni (ultimi 30 giorni)
IsTun
IsTun il 12 Mag 2019
Risposto: Vidhi Agarwal il 27 Set 2024
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);

Risposte (1)

Vidhi Agarwal
Vidhi Agarwal il 27 Set 2024
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!

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by