Include fft.m in Java Project
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello everyone!
I have a matlab function (let's call it mfun) which calls the fft. I use this mfun in Java code, through a class created by Matlab builder JA (R2010a), but I get a java error "Undefined function or method 'fft' for input arguments of type 'int32'". I guess that Java cannot access to the fft function, the .jar file only has one class with this mfun. So, how can I include fft in the .jar?
Thanks!
댓글 수: 0
채택된 답변
Rick Rosson
2011년 8월 31일
Hi Frank,
The issue is not with deploying fft using Builder JA, but rather with fft itself. The fft function does not support integer classes as input arguments.
Please try the following at the MATLAB Command Line:
x = int32(randi([-256 255],128,1));
X = fft(x);
Notice that you get the same error message.
You can, however, coerce the integer class input argument to double or single to perform the transformation:
X = fft(double(x));
OR
X = fft(single(x));
HTH.
Rick
추가 답변 (2개)
Rick Rosson
2011년 8월 31일
I think the easiest thing to do would be to modify the MATLAB source code for the time2rms function, and then re-deploy using the MATLAB Compiler and Builder JA.
There are two ways to modify the MATLAB code:
- Check the input arguments at the very beginning of the function to see if they are floating point. If not, coerce them right then and there, OR
- Find each instance where the function calls fft, and coerce the input argument at each call site.
To accomplish #1, you would need to use the isa function:
if ~( isa(x,'double') || isa(x,'single') )
x = double(x)
end
I am not sure which way is better, but both should work.
HTH.
Rick
참고 항목
카테고리
Help Center 및 File Exchange에서 Call MATLAB from Java에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!