現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
help me to write a code for processing an audio signal using taylor series
1 回表示 (過去 30 日間)
古いコメントを表示
clc;
clear all;
[x,Fs] = audioread('audioe.wav');
sound(x,Fs);
whos x
disp(Fs)
x = x(:,1);
dt = 1/Fs;
t = 0:dt:(length(x)*dt)-dt;
figure(1)
plot(t,x); xlabel('Seconds'); ylabel('Amplitude');
h = spectrum.periodogram; % create a periodogram spectral estimator.
figure(2)
psd(h,x,'Fs',Fs); % Calculates and plots the two-sided PSD.
%plot(psd(spectrum.periodogram,x,'Fs',Fs,'NFFT',length(x)));
y = interp(x,4);%resample data at a higher rate using lowpass interpolation
%[y, ty] = resample(x,t,Fs);
%y =resample(x,3,2);
figure(3)
subplot(211);
stem(x);
title('Original Signal');
subplot(212);
stem(y);
title('Interpolated Signal');
SNR = snr(x);
SNR1 = snr(y);
a=2;
N =2;
z = taylor(x,a,N);
plot(z);
3 件のコメント
Elavarasi E
2019 年 9 月 20 日
i need to sum up three different dimensions, which is in taylor series. this is in matrix and the equation is :
(x+h) = x + (h.*diff(x)) + (h^2.*diff(x,2))./factorial(2);
(x+h) is of same length of 'x' while first derivative is one lessthan 'x' and second derivative is of two lessthan of 'x'.
Elavarasi E
2019 年 9 月 28 日
In an audio signal, I need to find the intermediate samples. To read the intermediate I make use of taylor series. Audio signal is read thro’ [x,Fs] = audioread('audioe.wav');
The taylor series am using is f(x+h) = f(x) + hf’(x) + h2f’’(x)/2! .
Were f(x) is ‘x’ . Accordingly f(x+h) should be x(t)+h but this doesn’t work. ‘h’ is some intermediate value.
clc;
close all;
clear all;
[x,Fs] = audioread('audioe.wav');
sound(x,Fs);
whos x
disp(Fs)
x= x(:,1);
dt = 1/Fs;
t = 0:dt:(length(x)*dt)-dt;
figure(1)
plot(t,x);
xlabel('Seconds');
ylabel('Amplitude');
dx = gradient(x);
dx2 = gradient(dx);
for t = 0:dt:(length(x)/4*dt)-dt
for x = 0:dt:(length(x)/4*dt)-dt
h = 0.347;
y(t+h) = x + (h.*dx) + (h^2.*dx2)./factorial(2);
end
end
figure(2)
% hold on
plot(t,x,'blue',t,y, 'red')
% hold off
legend('actual','taylorseries')
for loop doesnt work
採用された回答
darova
2019 年 9 月 20 日
Try gradient instead of diff
dx = gradient(x);
dx2 = gradient(dx);
result = x + (h.*dx) + (h^2.*dx2)./factorial(2);
21 件のコメント
Elavarasi E
2019 年 9 月 23 日
this is my code to read an audio signal
clc;
close all;
clear all;
[x,Fs] = audioread('audioe.wav');
sound(x,Fs);
whos x
disp(Fs)
x= x(:,1);
dt = 1/Fs;
t = 0:dt:(length(x)*dt)-dt;
figure(1)
plot(t,x);
xlabel('Seconds');
ylabel('Amplitude');
h = 0.347;
dx = gradient(x);
dx2 = gradient(dx);
for t1 = 0:dt:(length(x)*dt)-dt
(x+h) == x + (h.*dx) + (h^2.*dx2)./factorial(2);
end
figure(2)
hold on
plot(t,x,'blue',t1(:,1:length(x+h)),(x+h), 'red')
hold off
legend('actual','taylorseries')
the lengths same now. but, the for loop does not excecute nor do it shows me any error except doble equal sign. the second figure does appear at all.
darova
2019 年 9 月 23 日
What does it mean?
for t1 = 0:dt:(length(x)*dt)-dt
(x+h) == x + (h.*dx) + (h^2.*dx2)./factorial(2);
end
Elavarasi E
2019 年 9 月 23 日
am equating the time t1 to t which nothing but dt . in this for loop i get an error wrt equal sign
Elavarasi E
2019 年 9 月 23 日
i need to process the read audio signal through taylor series. the length of the fine processed audio signal will be same as that of the actual signal. so i use a 'for' loop as the length of time 't' and plot the fine processed signal wrt 't'. but the for loop is not exceuting nor does it show me any error.
Elavarasi E
2019 年 9 月 23 日
the only error it shows is about equal sign n it guides me to use double equal sign.
Elavarasi E
2019 年 9 月 23 日
f(x+h) = f(x) + hf'(x) + h^2f''(x)/2!
i need to find the intermediate value of f(x) at instance z = x+dt where both time n signal are variable.
darova
2019 年 9 月 23 日
Please show the error occurs and why it guides you to use double sign
Why it doesn't work?
result = x + (h.*dx) + (h^2.*dx2)./factorial(2);
Elavarasi E
2019 年 9 月 28 日
In an audio signal, I need to find the intermediate samples. To read the intermediate I make use of taylor series. Audio signal is read thro’ [x,Fs] = audioread('audioe.wav');
The taylor series am using is f(x+h) = f(x) + hf’(x) + h2f’’(x)/2! .
Were f(x) is ‘x’ . Accordingly f(x+h) should be x(t)+h but this doesn’t work. ‘h’ is some intermediate value.
this my modified code again does not work for the "for" loop
clc;
close all;
clear all;
[x,Fs] = audioread('audioe.wav');
sound(x,Fs);
whos x
disp(Fs)
x= x(:,1);
dt = 1/Fs;
t = 0:dt:(length(x)*dt)-dt;
figure(1)
plot(t,x);
xlabel('Seconds');
ylabel('Amplitude');
dx = gradient(x);
dx2 = gradient(dx);
for t = 0:dt:(length(x)/4*dt)-dt
for x = 0:dt:(length(x)/4*dt)-dt
h = 0.347;
y(t+h) = x + (h.*dx) + (h^2.*dx2)./factorial(2);
end
end
figure(2)
% hold on
plot(t,x,'blue',t,y, 'red')
% hold off
legend('actual','taylorseries')
Elavarasi E
2019 年 9 月 30 日
clc;
close all;
clear all;
[x,Fs] = audioread('audioe.wav');
sound(x,Fs);
whos x
disp(Fs)
x= x(:,1);
dt = 1/Fs;
t = 0:dt:(length(x)*dt)-dt;
figure(1)
plot(t,x);
xlabel('Seconds');
ylabel('Amplitude');
for t = 1:dt:(length(x)/4*dt)-dt
for k = 1:length(x)/32
dx(k) = gradient(x(k));
dx2(k) = gradient(dx(k));
h = 0.347;
y(t+h) = x(k) + (h.*dx(k)) + (h^2.*dx2(k))./factorial(2);
end
end
figure(2)
% hold on
plot(t,x,'blue',t,y, 'red')
% hold off
legend('actual','taylorseries')
Results :
Name Size Bytes Class Attributes
x 2395137x2 38322192 double 44100
Array indices must be positive integers or logical values.
Error in eaudiodiff (line 24)
y(t+h) = x(k) + (h.*dx(k)) + (h^2.*dx2(k))./factorial(2);
1) guide me to solve theabove error.
2) when i execute these statements individually on comment window
k = 1:length(x)/32
dx(k) = gradient(x(k))
dx2(k) = gradient(dx(k))
h = 0.347
y(t+h) = x(k) + (h.*dx(k)) + (h^2.*dx2(k))./factorial(2)
I get an error as memoryspace exceeded.
darova
2019 年 9 月 30 日
I don't have your data so i generated some random
n = 100;
Fs = 2000;
dt = 1/Fs;
t = 0:dt:(n*dt)-dt;
x = 0.05*sin(2000*t) + cos(100*t); % random data
dx = gradient(x);
dx2 = gradient(dx);
h = 0.347;
x1 = x + h.*dx + h^2.*dx2./factorial(2);
plot(t,x,'blue',t,x1, '.r')
legend('actual','taylorseries')
xlabel('Seconds');
ylabel('Amplitude');
And here are the results
![img1.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/240514/img1.png)
![img2.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/240515/img2.png)
Slightly differs is it?
Elavarasi E
2019 年 10 月 1 日
Appreciate your kindness. Ya it differs. Actually I have to process it on any audio signal.
when I execute the entire code I get these errors
Array indices must be positive integers or logical values.
Error in eaudiodiff (line 24)
y(t+h) = x(k) + (h.*dx(k)) + (h^2.*dx2(k))./factorial(2);
1) guide me to solve the above error.
2) when i execute these statements individually on comment window
k = 1:length(x)/32
dx(k) = gradient(x(k))
dx2(k) = gradient(dx(k))
h = 0.347
I get the correct values but when the below equation is executed
y(t+h) = x(k) + (h.*dx(k)) + (h^2.*dx2(k))./factorial(2)
I get an error as memoryspace exceeded.
need to rectify these two errors.
Elavarasi E
2019 年 10 月 1 日
ur code is correct but its only for one instance at x1, which should actually be x+h, i.e x1 = (x+h). i need to evaluate it for all the values of x displaced by the instance 'h' wrt to 't'.
i.e., y(t+h) = x(k) + (h.*dx(k)) + (h^2.*dx2(k))./factorial(2)
y(0+h) is the output at instance x(0). were x(0) is calculated using taylor series. this has to repeat for all 't'.
darova
2019 年 10 月 1 日
Maybe try this
result = x + (h.*dx) + (h^2.*dx2)./factorial(2);
result = result + h;
% result = result - h;
Elavarasi E
2019 年 10 月 2 日
Very much appreciate your prompt response.
here I need to find the value at instance (t+h) but result = result + h will give me output + h and not output at time (t+h).
i.e if output is 20 , t= 5 and h = 0.112
as per result = result + h; i'll get the result as 20.112 at time t = 5 but at the instance t = 5.112 it will be some 'xx' value.
I need this 'xx' value. this can be done only by varying both time and amplitude.
darova
2019 年 10 月 2 日
So add it to t
x1 = x + (h.*dx) + (h^2.*dx2)./factorial(2);
t1 = t + h;
plot(t,x,t1,x1)
Elavarasi E
2019 年 10 月 23 日
hi !
let 'n' be a sequence. it should be broken down into samples of length 1024.
i.e n/1024 = y spectrum.
i should plot this 'y' spectrum as overlapped spectrums with an overlap of 48 samples on each spectrum. the last spectrum can be padded with zeroes at the last.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Signal Generation and Preprocessing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)