Reputation: 509
I have a long list of characterstics like this:
{freq: 0, amp: 1154.6588660054892, phase: 0.6811527708352859}
{freq: 1, amp: 233.76302050080815, phase: -2.277730816435749}
{freq: 2, amp: 143.2507105748049, phase: -1.6688604056674772}
{freq: 3, amp: 61.34267912110249, phase: -1.407276624718863}
{freq: 4, amp: 69.82165621191676, phase: 0.4484639726070131}
{freq: 5, amp: 124.7089820392834, phase: -2.69715415885439}
{freq: 6, amp: 98.10782045873147, phase: -2.257663813503815}
{freq: 7, amp: 45.692851840698864, phase: 2.0834837932685986}
{freq: 8, amp: 13.755486310098496, phase: -0.9882950412130524}
{freq: 9, amp: 37.04634258561415, phase: 1.0277190546903878}
{freq: 10, amp: 57.320618660063865, phase: 0.9419518346957391}
{freq: 11, amp: 5.566488239052793, phase: -1.1325389453638341}
{freq: 12, amp: 4.611944397255416, phase: 0.14233997398390724}
{freq: 13, amp: 66.65783488521923, phase: -1.592500420430998}
{freq: 14, amp: 28.96466186646502, phase: 2.507516417595699}
{freq: 15, amp: 49.2744858240047, phase: 2.7774600258970668}
{freq: 16, amp: 10.210149563013712, phase: -0.978331488766217}
{freq: 17, amp: 16.59276204808539, phase: -2.4968547381563684}
...
in an excel file. Each of these numbers describes a part of Cn in the equation below:
Cn is a Complex Number and is represented like this:
[amp]*e^(pi*i*[phase])
where [Freq] is n in the formula
hence the list of numbers go into this Cn.
This Video From 3D1B describes the concepts discussed here in great detail in an easy to follow way. (14min - 24min)
How can i compute Sn(x). So it would be
C0*e^[i*pi*((0))*x]/P + C1*e^[i*pi*((1))*x]/P + C2*e^[i*pi*((2))*x]/P
= in my case using the data above:
[1154]*e^(pi*i*[0.68])*e^[i*pi*((0))*x]/P + [233]*e^(pi*i*[-2.27])*e^[i*pi*((1))*x]/P + [143]*e^(pi*i*[1.66])*e^[i*pi*((2))*x]/P....... until my data is done
GOAL: How can i do this in matlab --> Solve Complete Sum
Upvotes: 1
Views: 179
Reputation: 1351
I reduce the data to your first three data points
amp = [1154.6588660054892, 233.76302050080815, 143.2507105748049];
phase = [0.6811527708352859, -2.277730816435749, -1.6688604056674772];
You can compute cn like this
cn = amp .* exp(pi* 1j * phase);
This is just a vector of your freq
for three data points:
n = 0:numel(amp)-1;
To compute Sn(x)
, I need x
and P
(shouldn't it be S_n(x,P)
?) [Update Use a vector for x
]:
x = 0:.5:30;
P = 18;
and Sn(x)
could be simply computed in a loop:
Sn = zeros(size(x));
for idx = 1:numel(x)
Sn(idx) = sum(cn.*exp(1j*pi.*n*x(idx)/P));
end
Plot Sn
:
plot3(real(Sn), imag(Sn), x);
xlabel("real(S_n)");
ylabel("imag(S_n)");
zlabel("time");
Upvotes: 1