請教一個metlab 程式?

2017-07-31 1:49 pm
就是
假設一個A段 把A的後面一半 加在B的前面
在把B段的後面的一半 加在C的前面
一直到結束
更新1:

不用能跑结果 只要大概就好

回答 (2)

2017-07-31 3:49 pm
✔ 最佳答案
N=陣列長度
M=round(N/2)
B(1:M) = A((N-M):N)
C(1:M) = B((N-M):N)

大概這樣
2017-07-31 5:15 pm
我現在是 這個程式問題,我聽我學姐說只要把FOR迴圈砍掉改成上面我要的就好,不知道你看不看得懂
clear all;
[z,fs,nbits] = wavread('English_horn.wav');
z = z(1:122880);
step = 1024;
calculation = round(length(z)/step);
Origin = 1;
time=(1:length(z))/fs;

for n = 1 : calculation
start = Origin;
z_frame = z((start+step*(n-1)):(start+step*n)-1, 1);


if n == 1
z_frame1 = z_frame;
z_frame1 = z_frame1.*hamming(step);
Z_frame1 = fft(z_frame1);
A = ifft(Z_frame1);


elseif n == 2
z_frame2 = z_frame;
z_frame2 = z_frame2.*hamming(step);
Z_frame2 = fft(z_frame2);
B = ifft(Z_frame2);
C = [A;B];
Z = [Z_frame1;Z_frame2];

else
z_frame2 = z_frame;
z_frame2 = z_frame2.*hamming(step);
Z_frame2 = fft(z_frame2);
B = ifft(Z_frame2);
C = [C;B];
Z = [Z;Z_frame2];

end
end

S1 = C;
X_add1 = [];
X_add2 = [];
for i = 1 : calculation
start = 1;
z_framel = S1((start+step*(i-1)):(start+step*i)-1, 1);
z_framel = z_framel.*hamming(step);
if mod(i,2) == 1
a = z_framel;
X_add1 = [X_add1;z_framel;z_framel];
else
b = z_framel;
X_add2 = [X_add2;z_framel;z_framel];
end

end
S = zeros(205,1);
X_add1 = [X_add1;S];
X_add1(1:205)=[];
X_add2 = [S;X_add2];
X_add2(size(X_add2)-204:size(X_add2),:)=[];
X_all = X_add1 + X_add2;
% 調整奇偶視窗位置,奇偶視窗合併
sound(real(2*X_all),fs);
I = z;
In = real(X_all);
Ps=sum(I.^2);%signal power
Pn1=sum(In.^2);
Pn2=abs(Ps-Pn1);%noise power
sdr=10*log10(Ps/Pn2);


收錄日期: 2021-05-04 02:22:06
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20170731054901AAeMqcX

檢視 Wayback Machine 備份