Is there a way to find the impulse response of the given system without using a loop?
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Is it possible to modify this code so that it would work without using any loop for the given system.
%y[n] = 1/3(x[n]-x[n-3])
y = zeros(1,21);
for i = 1:1:21
if i <= 3
y(i) = x(i)*(1/3);
else
y(i) = (x(i)-x(i-3))*(1/3);
end
end
0 Commenti
Risposte (2)
Ram Sreekar
il 26 Giu 2023
Modificato: Ram Sreekar
il 26 Giu 2023
Hi Akash knrs,
It is possible to calculate y without using a loop. You can refer to the example code given below.
% Consider,
x = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21];
y = zeros(1,21);
y(1:3) = x(1:3) * (1/3);
y(4:end) = (x(4:end) - x(1:end-3)) * (1/3);
Hope this helps you resolve your query.
0 Commenti
Mahesh Chilla
il 26 Giu 2023
Hi Akash!
Assuming that the array "x" is the unit impulse. To solve this, you can create an array of "x" which is shifted by 3 units to the right.
The following code will solve this
n = 1:21 ; %defining an interval
x = (n==0) ; % unit impulse
x3 = (n==3) ; % unit impulse shifted by 3 units to the right
y = (x-x3)/3 ;
To learn more about the functions used in the code, refer the MATLAB's documentation.
- https://www.mathworks.com/help/signal/gs/impulse-step-and-ramp-functions.html
Hope this helps,
Thank you!!
0 Commenti
Vedere anche
Categorie
Scopri di più su Get Started with 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!