??? Undefined function or method 'FFT ' for input arguments of type 'char'.

Heeeeey everyone,
My question is pretty general. I keep getting the following error when I try to run my simulation:
??? Undefined function or method 'FFT' for input arguments of type 'char'.
I am not sure why I am getting this error, as I am not explicitly calling on the FFT function. I did some background reading on this error type and found out that it has to do with specifying the correct path name.
The thing is, I am calling a user defined function called "fft1", which is an "altered" version of the discrete fourier transform. fft1 uses the actual fft function that is provided by MATLAB.
Can anyone help me fix my problem? I feel like I have set the path correctly, but I continue to get this error. Does it have something to do with my fft1 function?
Thanks,
Sarah

 Accepted Answer

Do you have signal processing toolbox?
If so, I would recommend that you put a debug stop inside fft1 at where the function fft is called to make sure the inputs make sense. It sounds like your inputs are not correct.

4 Comments

It looks like Sarah made the function with a bad name which included spaces. "FFT Field Analysis.m" errored out with the spaces inside the name.
Yeah, sorry everyone!!! The problem was so simple, and I led you guys in the wrong direction. I really apologize for my error. To Kevin and the rest of you, thanks so much for patiently helping me on this!
how did u remove this problem?.. i am facing the same prob. i was taking fft2 of an image and getting the same error 'Undefined function 'fft' for input arguments of type 'char'.'
Sarah had a file name that had a space in the middle of it. Your .m file names must not have any spaces in the actual file name.

Sign in to comment.

More Answers (4)

This would probably not be caused by incorrect path names. It would be caused by trying to pass a string in to MATLAB's fft() routine as the data to be fft'd.
We do not have enough information about what fft1 does or how you are calling it in order to determine how the string got there. Kevin's suggestion to use the debugger is a good one: command
dbstop if error
and then run your program, and it will stop at the line that was the problem.

5 Comments

For example,
I have two columns of data in excel. Let us say one column represents time as a string (the date: MM/DD/YYYY 00:00:00). The other column represents some numerical-only data.
I use xlsread to read ALL the data. Then I process the numerical data using fft1 and plot it vs time (time acquired from the date strings in excel). The fft1 function is set up like so:
[f,y] = fft1[x,dt,KW]
Where f and y represent the frequency components, x is the input signal (in my case being the numerical data from excel), dt is a sampling time parameter (numerical value), and KW is a normalization factor (either 0 or 1). From what I can see, the data I am processing using fft1 is numerical, and thus I feel that I should not be getting the error.
Does this make any sense?
Question: is your file "fft1.m" or "fft 1.m" with a space between the fft and the 1 ? No spaces allowed in the name.
If you do indeed have a space, then
[f,y] = fft 1[x,dt,KW]
would be treated as a call to fft() with an argument string of '1[x,dt,KW]'
Note to that [] is list building in MATLAB, not function calling.
Try that dbstop if error and see where it ends up, and then copy that exact line here and report the class() of each variable the code is passing in.
Sorry about the large amount of questions - I am a beginner in MATLAB. Like Kevin suggested, i put dbstop if error inside my fft1 code. Then, I ran my other mfile (the one that processes the excel data using fft1). It simply gave me the same error:
??? Undefined function or method 'FFT ' for input arguments of type 'char'.
It did not specify a line. Did I run dbstop if error correctly?
BTW, it is named as fft1 without a space, and I have called it as such.
So for example, I put:
dbstop if error;
y = fft(x);
^This is inside of the mfile for my fft1 function. If I try to run it, I still get the same error.

Sign in to comment.

Make sure that fft1.m is either in the same directory you are working in or in one of the folders that is in your path.

8 Comments

As far as I know, I have the path set to a folder called MATLAB PRACTICE, where I have all of my work saved in. The subroutine fft1 is also located in this folder. The thing is, fft1 calls on fft. fft is a built-in MATLAB function located in the main MATLAB folder. Do I have to add the main MATLAB folder to my path? Does that have something to do with it?
Furthermore, I tried including the main MATLAB folder to my path, but it gives me the following error:
MATLAB cannot save changes to path
The pathfile. pathdef.m, might be read-only or might be in a directory for which you do not have write access.
Any suggestions on how to circumvent this??
You do not need to add a main matlab path, it should be able to find fft() without any direction.
It sounds like your inputs to fft() are screwed up. Put a stop on the function fft() and run it. Then check your inputs are not strings. xlsread may have made something a string without you knowing.
I agree with Kevin and Walter, sounds like your fft1() function is trying pass fft() something like fft('abc')
Hey Kevin,
I am a MATLAB beginner :( Can you give me an idea as to where that "stop" would go in my fft function?
So for example, I put:
dbstop if error;
y = fft(x);
^This is inside of the mfile for my fft1 function. If I try to run it, I still get the same error.
when it opens the editor at that line:
y = fft(x);
point your cursor at the x and tell us what it says, or go back to your command window and enter:
K>>whos x
The way I debug is:
Open the .m file that is calling fft() and go to that line in the .m file.
Next to the line number on the left, there is a line that looks like " - ". Click there, and a red dot should appear next to the line of code.
Then run your file, and it will pause at that line. Once it pauses, you can see exactly what your input variables are.
Tried it. x in this case is T1.Signal:
T1.Signal 16559 x 1 double
It reads it as a double...so I don't really understand why or where it is reading char...also look below at my new answer for further results.

Sign in to comment.

Another thing everyone...I just found this out. I can run the code by clicking the "evaluate selection" and letting it evaluate the whole block. I get the following:
T1.Signal 16559 x 1 double
T1.Time 16559 x 1 double
T1.f 8279 x 1 double
T1.y 8279 x 1 double
However, if I actually run the simulation using the run *.m button, I get the error mentioned previously.
Do you have the function called out as FFT(x) or fft(x)? Functions are case sensitive...

1 Comment

As far as I know, I don't have a function called out as FFT. That is why I am so confused...the error either refers to fft(x)(which I am aware of) or something called FFT(x) which I am not aware of.

Sign in to comment.

Categories

Find more on Measurements and Spatial Audio in Help Center and File Exchange

Asked:

on 10 Oct 2011

Commented:

on 13 Sep 2017

Community Treasure Hunt

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

Start Hunting!