how to calculate the convolution of two signal without using CONV() ?

조회 수: 113 (최근 30일)
Hi everyone, i was wondering how to calculate the convolution of two sign without Conv();. I need to do that in order to show on a plot the process. i know that i must use a for loop and a sleep time, but i dont know what should be inside the loop, since function will come from a pop-up menu from two guides.(guide' code are just ready);
option = get(handles.popupmenu1,'value');
option2 = get(handles.popupmenu2,'value');
// something that switch the func.
conv(x,h);
//plot the conv.
  댓글 수: 4
Image Analyst
Image Analyst 2018년 9월 25일
Not sure what that means. Why do you need a delay? Do you want to show a set of boxes representing the kernel moving along over the top of another set of boxes representing the signal? Doing the convolution is one thing (a really easy thing), but providing the animation, if that is what is required will be a lot harder.
Synchro_mdn
Synchro_mdn 2018년 9월 25일
Lets leave out that part, I just really need to know how to set the for loop for two different signal.

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

채택된 답변

Dimitris Kalogiros
Dimitris Kalogiros 2018년 9월 25일
close all
clearvars
%x=input('Enter x: ')
x=sin(2*pi*0.1.*(1:1:11));
%h=input('Enter h: ')
h=[1 2 3 4 5 3 1 -1];
% convolution
m=length(x);
n=length(h);
X=[x,zeros(1,n)];
H=[h,zeros(1,m)];
for i=1:n+m-1
Y(i)=0;
for j=1:m
if(i-j+1>0)
Y(i)=Y(i)+X(j)*H(i-j+1);
else
end
end
end
% plot results
figure;
subplot(3,1,1); stem(x, '-b^'); xlabel('n');
ylabel('x[n]'); grid on;
subplot(3,1,2); stem(h, '-ms');
xlabel('n'); ylabel('h[n]'); grid on;
subplot(3,1,3); stem(Y, '-ro');
ylabel('Y[n]'); xlabel('----->n'); grid on;
title('Convolution of Two Signals without conv function');
  댓글 수: 3
Allard Quek
Allard Quek 2022년 3월 12일
the first characters represent the colour and the second characters represent the shape:
'-b^': blue triangle
'-ro': red circle
'-ms': magenta square
maryam alyammahi
maryam alyammahi 2023년 2월 16일
How to make the graph starts from zero not one?

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

추가 답변 (5개)

Manoj Manu
Manoj Manu 2021년 8월 16일
close all
clearvars
%x=input('Enter x: ')
x=sin(2*pi*0.1.*(1:1:11));
%h=input('Enter h: ')
h=[1 2 3 4 5 3 1 -1];
% convolution
m=length(x);
n=length(h);
X=[x,zeros(1,n)];
H=[h,zeros(1,m)];
for i=1:n+m-1
Y(i)=0;
for j=1:m
if(i-j+1>0)
Y(i)=Y(i)+X(j)*H(i-j+1);
else
end
end
end
% plot results
figure;
subplot(3,1,1); stem(x, '-b^'); xlabel('n');
ylabel('x[n]'); grid on;
subplot(3,1,2); stem(h, '-ms');
xlabel('n'); ylabel('h[n]'); grid on;
subplot(3,1,3); stem(Y, '-ro');
ylabel('Y[n]'); xlabel('----->n'); grid on;
title('Convolution of Two Signals without conv function');

Sk Group
Sk Group 2021년 10월 25일
Convolution without conv function in MATLAB | Complete CODE | Explanation | Example And Output

Kiran K V
Kiran K V 2022년 6월 28일

clear all;

clc;

x = input ('Enter the first signal/sequence ');

h = input('Enter the second signal/sequence ');

Find the length of the individual signals, and thus the output

[~,L]= size (x);

[~,M] = size (h);

len y = L + M - 1

y = zeros (1, len_y);

len = 1:1en_y;

for i = 0 / l * eny

for j = 0/1 * eny

if ((i-j+1)>0 && (i-j+1)<=M && (j+1)<=L) y(i+1)=y(i+1)+x(j+1),^ * h(i-j+1);

end

end

end

disp (y)

stem (len, y)

  댓글 수: 1
Or Baron
Or Baron 2022년 7월 31일
what do you mean by y(i+1)=y(i+1)+x(j+1),^ * h(i-j+1); ? what does ,^ mean?

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


Muhammad
Muhammad 2023년 8월 27일
1 2 3
-1 2 3

Mehmet Eren Dikmen
Mehmet Eren Dikmen 2024년 3월 28일
Hi guys i need to find a matlab code which can take 2 inputs of 2 different signals and generates and y(t) signal. This y(t) signal must be a another signal. So I'm basicaly looking for a signal for output. This is soooo urgent

카테고리

Help CenterFile Exchange에서 Data Exploration에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by