Hi ! I am new in matlab and i have to write a matlab code to generate the signals: y(t)=3r(t+3)-6r(t+1)+3r(t)-3u(t-3) and y(t)= 2r(t‐2) + 4u(t‐1) +2 r(t).
Can you please help me ?

4 Kommentare

Walter Roberson
Walter Roberson am 27 Mär. 2021
What is r in this context?
Is u the unit step function?
Maria Thomaidou
Maria Thomaidou am 27 Mär. 2021
u is Unique Sloping Function and r is Unique Step Function
Walter Roberson
Walter Roberson am 27 Mär. 2021
r is t times u so if you implement u then you can easily implement r as well.
Maria Thomaidou
Maria Thomaidou am 29 Mär. 2021
The problem was that it was my first matlab lesson..And i found it hard!! Thank god i finally made it thanks anyway <3

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Kautuk Raj
Kautuk Raj am 3 Jun. 2023

0 Stimmen

The following code plots the functions pointed by you:
% Define the ramp function r(t)
r = @(t) t .* (t >= 0);
% Define the unit step function u(t)
u = @(t) 1 .* (t >= 0);
% Define the time range for the signals
t = -5:0.1:5;
% Define the first signal
y1 = 3*r(t+3) - 6*r(t+1) + 3*r(t) - 3*u(t-3);
% Define the second signal
y2 = 2*r(t-2) + 4*u(t-1) + 2*r(t);
% Plot the signals
subplot(2,1,1)
plot(t,y1)
xlabel('t')
ylabel('y(t)')
title('Signal y(t) = 3r(t+3) - 6r(t+1) + 3r(t) - 3u(t-3)')
subplot(2,1,2)
plot(t,y2)
xlabel('t')
ylabel('y(t)')
title('Signal y(t) = 2r(t-2) + 4u(t-1) + 2r(t)')
The resultant plots look like:

1 Kommentar

Walter Roberson
Walter Roberson am 3 Jun. 2023
We do not encourage people to post complete solutions to homework problems.
The regular volunteers sometimes post code for problems that are similar to what the user is asking for, that illustrate the major steps, so that the user would need to examine the code and figure out how it works in order to answer their homework.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 27 Mär. 2021

Kommentiert:

am 3 Jun. 2023

Community Treasure Hunt

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

Start Hunting!

Translated by