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

31 次查看(过去 30 天)
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
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 CenterFile Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by