- The input argument x is assigned internally in line 3. You should remove it.
- What's the output of the function IFDT? There is no process to calculate C.
- Also, why is x calculated at the end of the function? Wasn't x an input for your function?
- What is k in line 5 for?
I want change the matlab code to C code with MATLAB Coder!
조회 수: 5 (최근 30일)
이전 댓글 표시
i want to chage the mathlab code to C code with MATLAB coder
I want to solve the IDFT and DFT in C compiler but C compiler no apply complex in exp function.
so i use the MATLAB Coder first time
but I have little problem in Check for Run-Time Issues
function C=IDFT(x)
N=4;
x=[1 2 2 1];
n=0:N-1;
K=0:N-1;
WN=exp(-j*2*pi/N).^n;
for m=1:N
X(m)=sum(x.*WN.^(m-1));
end
df=1/500;
f=df*[0:500];
W=exp(-j*2*pi.*f);
xf=zeros(1,length(f));
for m=1:N
xf=xf+x(m)*W.^(m-1);
end
for m=1:N
x(m)=sum(X.*(WN.^(-1)).^(m-1))/N;
end
and MATLAB Coder return error
line NO 8 Variable 'X' has not been assigned. To assign the variable, use a complete assignment and not a subscript. Code generation does not support creating arrays via indexing.
line NO 15 Cannot assign a complex value into a non-complex location.
How can i do?
댓글 수: 0
답변 (1개)
Angelo Yeo
2023년 11월 14일
편집: Angelo Yeo
2023년 11월 14일
Before using MATLAB Coder, there are a few things to check.
Regarding the error you encountered, any variables must be explicitly assigned with its type and size when you translate M file into C/C++. This is because C language is not as dynamic as MATLAB. See how to make MATLAB code suitable for C/C++ code generation in the doc below.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!