mmorise / beginning_asa Goto Github PK
View Code? Open in Web Editor NEWひたすら楽して音響信号解析:プログラム置き場
Home Page: https://www.coronasha.co.jp/np/isbn/9784339009392/
ひたすら楽して音響信号解析:プログラム置き場
Home Page: https://www.coronasha.co.jp/np/isbn/9784339009392/
初めまして
私は今、matlabで離散フーリエ変換をfft関数などを使わずにプログラムを書いています。「dft_size×dft_size の行列」と「dft_size×1 の行列」の積により DFT 計算を行うプログラムを書きたいのですが上手く書けなくて困っています。
下記プログラムの
X_real=zeros(dft_size,1);
X_imag=zeros(dft_size,1);のX_real=zeros()内を(dft_size,dft_size)に変えて、
scriptファイルの
A=zeros(dft_size,1);
T=zeros(dft_size,1);のA()内を(dft_size,dft_size)に書き換えればよいと思ったのですが、上手くいきませんでした。
アドバイスを頂けたら幸いです。
以下、プログラムリスト
//////
function [X_real,X_imag]=DFT(x_real,x_imag,dft_size)
X_real=zeros(dft_size,1);
X_imag=zeros(dft_size,1);
for k=1:dft_size,
for n=1:dft_size,
w_real=cos(-2pi(k-1)(n-1)/dft_size);
w_imag=sin(-2pi*(k-1)(n-1)/dft_size);
X_real(k,1)=X_real(k,1)+w_realx_real(n,1)-w_imagx_imag(n,1);
X_imag(k,1)=X_imag(k,1)+w_realx_imag(n,1)+w_imag*x_real(n,1);
end
end
////////
clear;
dft_size=60;
x_real=audioread('test.wav',[1 dft_size]);
x_imag=zeros(dft_size,1);
[X_real,X_imag]=DFT(x_real,x_imag,dft_size);
A=zeros(dft_size,1);
T=zeros(dft_size,1);
frequency=zeros(dft_size,1);
for k=1:dft_size,
A(k,1)=sqrt(X_real(k,1)*X_real(k,1)+X_imag(k,1)*X_imag(k,1));
T(k,1)=atan(X_imag(k,1)/X_real(k,1));
frequency(k,1)=k-1;
end
subplot(2,1,1);
stem(frequency,A);
subplot(2,1,2);
stem(frequency,T);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.