I want to use MATLAB Generated Code in Qt Creator

16 次查看(过去 30 天)
Hello, I wrote MATLAB Script to find FFT.
%% TestFFT
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
L = 1500; % Length of signal
t = (0:L-1)*T; % Time vector
S = 0.8 + 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);
X = S + 2*randn(size(t));
Y = takeFFT(X);
plot(Fs/L*(0:L-1),abs(Y))
%%
function [output] = takeFFT(input)
output = fft(input);
end
It generated lots of files. How will I figure it out which code I have to copy paste in Qt Creator
  1 个评论
Ezra Stein
Ezra Stein 2024-3-7
Hi Sajjad,
To incorporate the generated code into another project, you will need most of the generated source and header files located directly within the codegen/lib folder. However, you will not necessarily need the other files or folders in this directory.
In the Qt project, you can invoke the generated FFT code by calling the "takeFFT" entry point located in the takeFFT.h header. An example demonstrating how to invoke this entry point should be available in the generated 'examples' folder. This will contain some code that demonstrates how to use the generated entry-point function.
The example will first call the takeFFT_initialize() function, then call the takeFFT() entry point function, and finally call the takeFFT_terminate() function. The initialize and terminate functions are needed to ensure global state that is used by the generated code is correctly initialized and destroyed. When incorporating the code into your project, the initialize and terminate functions should be called at the beginning and end of your program respectively.
For more information, see the deployment section of the MATLAB Coder documentation: https://www.mathworks.com/help/coder/deployment.html?s_tid=CRUX_lftnav
Best,
-Ezra

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Coder 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by