What's new

Help I want the MATLAB CODE

SOWHAT0819

Addict
Established
Let's manually compute y(n) = 2x(−n + 1) using the given sequence x(n) · {−4, 3, 4, 3, −5, 1, −5, −2, −5, 4, 1}: y(n) = 2x(−n + 1)
y(0) = 2x(−(0) + 1) = 2x(1) = 2 × 4 = 8
y(1) = 2x(−(1) + 1) = 2x(0) = 2 × 3 = 6
y(2) = 2x(−(2) + 1) = 2x(−1) = 2 × 4 = 8
y(3) = 2x(−(3) + 1) = 2x(−2) = 2 × 3 = 6
y(4) = 2x(−(4) + 1) = 2x(−3) = 2 × (−5) = −10
y(5) = 2x(−(5) + 1) = 2x(−4) = 2 × 1 = 2
y(6) = 2x(−(6) + 1) = 2x(−5) = 2 × (−5) = -10
y(7) = 2x(−(7) + 1) = 2x(−6) = 2 × (−2) = −4
y(8) = 2x(−(8) + 1) = 2x(−7) = 2 × (−5) = −10
y(9) = 2x(−(9) + 1) = 2x(−8) = 2 × 4 = 8
y(10) = 2x(−(10) + 1) = 2x(−9) = 2 × 1 = 2

I want the matlab code to get the signal sketch!!!
 
Here is the MATLAB code to plot the signal y(n) based on the manual computation you provided:

Code:
% Given sequence x(n)
x = [-4, 3, 4, 3, -5, 1, -5, -2, -5, 4, 1];

% Compute y(n) based on the formula y(n) = 2x(-n + 1)
n = 0:length(x)-1;
y = zeros(size(x));

for k = 1:length(x)
    y(k) = 2 * x(max(1, -k + 2));
end

% Plot the signal
stem(n, y, 'LineWidth', 1.5);
xlabel('n');
ylabel('y(n)');
title('Plot of the Signal y(n) = 2x(-n + 1)');
grid on;

You can copy and paste this code into a MATLAB script file or the MATLAB command window to generate the plot of the signal y(n) based on the computed values.
 

Similar threads

Users search this thread by keywords

  1. matlab
Back
Top