how can I sum 2 or more sine waves into one sine wave?

31 ビュー (過去 30 日間)
Khuram
Khuram 2015 年 4 月 6 日
コメント済み: Khuram 2015 年 4 月 6 日
I have 2 questions: 1: How can I sum two or more sine waves into one sine wave? as the example shown below
2: The code below suppose to give only 3 sine waves and the I have to sum them, I don't know how can remove the forth line and then sum the other 3?
Thank you in advance for helping
clc;clear
k=0.5;
rho=1600;cv=725;aLf=k/(rho*cv);
day=1;L=0.4;
nx=5; nxp=nx+1; dx=L/nx;nxx=dx*(1:nxp);
td=day*24*3600;nt=60;ntp=nt+1;dt=td/nt;
%--------------------------------------------------------------------------
Tem=[4 4 4 3 3 3 3 4 5 6 7 8 9 10 10 10 10 9 8 7 7 6 5 4];
x=(1:(24*day))*3600;
f = fit(x.',Tem.','fourier2');
coeffs = coeffvalues(f);
w=coeffs(:,6);
%--------------------------------------------------------------------------
Ti=10;
t=linspace(0,td,ntp);x=linspace(0,L,nxp);
T=zeros(1,ntp);depth=0.1;
for h=1:2:5;
Ts(h)=coeffs(:,h);
if h>3
a=2;
else
a=1;
end
for j=1:ntp
time(j)= (j)*dt;
Tx=Ti+(Ts(h)*(exp(-(sqrt(w/(2*aLf))*depth))))*(sin(a*w*time(j)-((sqrt(w/(2*aLf))*depth))));
T(j)=Tx;
end
TM(h,:)= T;
end
plot(t/3600,TM,'linewidth',2); hold on; xlabel('time (t)'); ylabel('Surface Temperature(Ts)');grid on

採用された回答

michael scheinfeild
michael scheinfeild 2015 年 4 月 6 日
just z=x+y if x and y different lengths you can interpolate it to correct length

その他の回答 (1 件)

Roger
Roger 2015 年 4 月 6 日
result = sinwave1 + sinwave2;(make sure they r with same length)

カテゴリ

Help Center および File ExchangeFourier Analysis and Filtering についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by