Convolution of e and cosine using Matlab

am trying to perform convolution in Matlab using the function conv() and then plot the result. Below is my code.
tstep = 0.1;
time = 10;
t = -time:t:time;
x = cos(2*pi*t);
h = exp(-t);
y = conv(x,h,'same');
plot(t,y);

답변 (2개)

Image Analyst
Image Analyst 2017년 9월 14일

0 개 추천

I see no reason why you should get that kind of output given the h and x you have defined. In fact if you look at the plots, it makes perfect sense what you are seeing. Look at the plots and tell me if you don't now see why convolving those two gives the bottom output.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
Fs = 16000;
Ts = 1/Fs;
fc = 1000;
Tc = 1/fc;
t = 0:Ts:Tc;
% LTI impulse response h(t) = exp(-1000*t)
h = exp(-1000*t);
% angular frequency wc = 2*pi*fc
wc = 2*pi*fc;
% the signal x(t) = sin(wc*t)
x = sin(wc*t);
% convolution of x(t) and h(t)
y = conv(x,h,'same');
subplot(3, 1, 1);
plot(t, h, 'LineWidth', 2);
grid on;
xlabel('t', 'FontSize', fontSize);
ylabel('h', 'FontSize', fontSize);
subplot(3, 1, 2);
plot(t, x, 'LineWidth', 2)
grid on;
xlabel('t', 'FontSize', fontSize);
ylabel('x', 'FontSize', fontSize);
subplot(3, 1, 3);
plot(t, y, 'LineWidth', 2)
grid on;
hold on
stem(t,y)
xlabel('t', 'FontSize', fontSize);
ylabel('y = x**h', 'FontSize', fontSize);
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
% Get rid of tool bar and pulldown menus that are along top of figure.
% set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
% set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
Jaiprakash
Jaiprakash 2024년 2월 9일

0 개 추천

clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
Fs = 16000;
Ts = 1/Fs;
fc = 1000;
Tc = 1/fc;
t = 0:Ts:Tc;
% LTI impulse response h(t) = exp(-1000*t)
h = exp(-1000*t);
% angular frequency wc = 2*pi*fc
wc = 2*pi*fc;
% the signal x(t) = sin(wc*t)
x = sin(wc*t);
% convolution of x(t) and h(t)
y = conv(x,h,'same');
subplot(3, 1, 1);
plot(t, h, 'LineWidth', 2);
grid on;
xlabel('t', 'FontSize', fontSize);
ylabel('h', 'FontSize', fontSize);
subplot(3, 1, 2);
plot(t, x, 'LineWidth', 2)
grid on;
xlabel('t', 'FontSize', fontSize);
ylabel('x', 'FontSize', fontSize);
subplot(3, 1, 3);
plot(t, y, 'LineWidth', 2)
grid on;
hold on
stem(t,y)
xlabel('t', 'FontSize', fontSize);
ylabel('y = x**h', 'FontSize', fontSize);
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);

댓글 수: 1

Image Analyst
Image Analyst 2024년 2월 9일
Yep, that was my code in my answer. But you do not need to post my code here as your answer to this 6 year old question.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

질문:

2017년 9월 13일

댓글:

2024년 2월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by