Hi, so I am trying to plot the furrier transform of a set of data. A is a row vector with:
A = [0.0001:0.0001:0.08]
And B is the row vector with the Y values for the sound wave, with the same dimension so that a function g can be defined as mapping from every nth element of A to every nth element of B
The function that I came up to give me the furrier transform was:
function [ f_intensity ] = FT_g( f )
f_intensity = sum(B.*exp(-2*pi*1i*f.*A));
end
Both A and B are in my workspace but it keeps saying that the variable B is undefined.
>> FT_g(1)
Undefined function or variable 'B'.
Error in FT_g (line 3)
f_intensity = sum(B.*exp(-2*pi*1i*f.*A));
Anyone has any idea how I could solve this?

1 Kommentar

Matt J
Matt J am 7 Feb. 2019
I am trying to plot the furrier transform
Not to be confused with the fuzzier transform... ;)

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Star Strider
Star Strider am 7 Feb. 2019

0 Stimmen

You need to pass ‘A’ and ‘B’ as arguments to your funciton:
function [ f_intensity ] = FT_g( f, A, B )
Then call it the same way.
Note that ‘A’, ‘B’, and ‘f’ all have to have the same dimensions.

2 Kommentare

But that wouldnt work for me
I basiclly need this
B and A have already the same dimansion, 1x800 double, f cant have the same dimansion, f is just one value that I will use to plot( A[n] , f ). Is there any other way to make this work?
If ‘f’ is one frequency, I would do something like this:
A = [0.0001:0.0001:0.08];
B = sin((0 : 50 : 150)'*A); % Create ‘B’
f = 10;
f_intensity = @(f,A,B) sum(B.*exp(-2*pi*1i*f.*A));
figure
plot(A, abs(f_intensity(f,A,B)))
grid
See if that does what you want.

Melden Sie sich an, um zu kommentieren.

Produkte

Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by