[問題] 將function和fprintf用在迴圈的問題??已回收
原本的程式是這樣..
clear;
clc;
sig = wavread('Piano.ff.A4.wav');
sig1 = wavread('Piano.ff.C7.wav');
.... <==要load很多的音檔進來
N = 512;
step = 256;
fs = 22050;
fp = fopen('D:\SamplePoint.txt','w');
[mag,pts] = locatespeech(sig,N,step,fs);
[mag1,pts1] = locatespeech(sig1,N,step,fs);
.....
fprintf(fp,'%d %d \n',pts,pts1,.....); <===這邊需要把function中的
pts,pts1,... 另存起來
fclose(fp);
但一直這樣重複很麻煩~想用for迴圈來控制
clear;
clc;
sig = wavread('Piano.ff.A4.wav');
sig1 = wavread('Piano.ff.C7.wav');
....
N = 512;
step = 256;
fs = 22050;
fp = fopen('D:\SamplePoint.txt','w');
for i= 1:n
[mag(i),pts(i)] = locatespeech(sig(i),N,step,fs);
fprintf(fp,'%d \n',pts(i));
end
fclose(fp);
錯誤訊息如下:
??? Undefined function or method 'sig' for input arguments of type 'double'.
Error in ==> EndPointDe at 16
[mag(i),pts(i)] = locatespeech(sig(i),N,step,fs);
在 locatespeech(sig(i),N,step,fs); 和 fprintf 裡面會有錯 好像是i不能這樣擺
想請問一下我需要怎麼改才可以讓function和fprintf使用迴圈??
謝謝!!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.124.72.230
推
11/15 17:03, , 1F
11/15 17:03, 1F
→
11/15 17:14, , 2F
11/15 17:14, 2F
※ 編輯: a95297 來自: 140.124.72.230 (11/15 17:19)
推
11/15 17:27, , 3F
11/15 17:27, 3F