Multi sine waves function

조회 수: 20 (최근 30일)
Kanard
Kanard 2018년 5월 5일
댓글: Star Strider 2018년 5월 5일
Hello, right now I don't know how to create a multi sinus function with frequency from 1kHz to 2 kHz, with Amplitude varies from 0.25 to 1, in time from -2.5 to 2.5 second. I have tried with a loop 'for' but the problem is matrice t and f can't multiply with each other because of size.
for f = 1000:200:2000
A(n) = 1:-0.75/(length(f)-1):0.25;
V(n) = A(n)*sin(2*pi*f.*t + phi);
end
can someone help me with this?
  댓글 수: 1
Kanard
Kanard 2018년 5월 5일
can anyone check if what I wrote here is correct or not.
ts = 1/100;
t = -0.25:ts:0.25;
f = 400:200:3000;
A = 1:-0.75/(length(f)-1):0.25;
V = 0;
phi = rand(1,14);
for i = 1:14
V = V + A(1,i)*sin(2*pi*f(1,i)*t + phi(1,i));
plot(t,V(1,:));
hold on
end

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2018년 5월 5일
I’m not certain what result you want.
Your posted code doesn’t show any oscillations when I run it. I would change the argument of the sin function to divide by the number of elements of ‘t’ in order to show the oscillations:
V = V + A(1,i)*sin(2*pi*f(1,i)*t/numel(t) + phi(1,i));
Beyond that, I have no suggestions.
  댓글 수: 2
Kanard
Kanard 2018년 5월 5일
Hello, thanks for your reply, what I want is a function, which is a sum of many other sinusoidal signals, which frequencies and Amplitudes are in the range above. I tried to assign F and A to matrices and calculate each signal then plot all of them into a single figure. However i'm not sure if this is correct or not.
Star Strider
Star Strider 2018년 5월 5일
My pleasure.
Your code calculates and plots the evolving sum of all the waveforms, so if that’s what you want to do, it’s working.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by