フィルターのクリア

Discrete convolution.

2 ビュー (過去 30 日間)
omar chavez
omar chavez 2011 年 11 月 26 日
Hi, im trying to make certain examples of convolution codes for a function with N elements. so far I have done this. But I wish to find out a way so that it can be implemented on C too. any ideas or help?
clear all; close all; clc
x=[1 2 3]
h=[-1 0 3]
Z=[0]
[M,N]=size(x)
[L,O]=size(h)
a=1
A=N+O-1
suma=[0]
for n=1:1:N
for o=1:1:O
y(n,o)=x(n)*h(o)
end
end
s=fliplr(y);
n=-1*(N-1);
for r=1:A
Yfor(r)=sum(diag(s,n))
n=n+1;
end
Yconv=fliplr(Yfor)
%Yfor=0
%Yfor(1)=y(1,1)
%Yfor(2)=y(2,1)+y(1,2)
%Yfor(3)=y(3,1)+y(2,2)+y(1,3)
%Yfor(4)=y(3,2)+y(2,3)
%Yfor(5)=y(3,3)
Y=conv(x,h)
figure, stem(x)
grid on
figure,stem(Yconv) grid on
  2 件のコメント
Image Analyst
Image Analyst 2011 年 11 月 26 日
Any reason why you're not using the built-in conv() function?
Walter Roberson
Walter Roberson 2011 年 11 月 26 日
Everything other than the conv() and the graphics should be easy to do in C.
For example, since you do not use s after taking the diag() of it, you can just design your equivalent to diag to index right to left instead of left to right.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by