How to generate C code for the matlab function "kurtogram"?

Hello,
I am trying to generate C code for my Matlab code. My Matlab code runs perfectly without any problems.
To generate the C code, I am using the Matlab C coder.
However, while trying to generate C code for the Matlab function kurtogram I always get some errors. When I try generate C code for kurtogram without any output parameters, I am able to generate C code.
Does anyone know how to solve this or what I am possibly doing wrong.
This is the function I would like to have in C code:
function [fc, BW] = causprobieren (x,sampRate)
double fc
double BW
[~, ~, ~, fc, ~, BW] = kurtogram(x, sampRate);
end
I am using this script for testing the function:
sampRate = 1000;
X = X';
[fc, B] = causprobieren(X(1:2500),sampRate)

回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 1 月 30 日

0 投票

double fc
is the same thing as
double('fc')
which means to convert the character codes for 'f' 'c' to double precision and display them. It has nothing to do with declaring fc to be double precision.
You need to assign zeros of appropriate size to fc before you make the call, or you need to use coder.varsize().

3 件のコメント

HF
HF 2021 年 1 月 31 日
Hello, thank you for your answer. I tried to change my code as suggested but I am still not able to generate C code.
Here is my code:
function [fc, BW] = causprobieren (x,sampRate)
%#codegen
a = zeros(1,1);
b = zeros(1,1);
coder.varsize('a');
coder.varsize('b');
[~, ~, ~, a, ~, b] = kurtogram(x, sampRate);
% kurtogram(x, sampRate);
fc = a;
BW = b;
end
Walter Roberson
Walter Roberson 2021 年 1 月 31 日
When I read the documentation, it looks like in this case you should not initialize a and b
HF
HF 2021 年 1 月 31 日
I already tried this option too, but I am still not able to generate C code:
function [fc, BW] = causprobieren (x,sampRate)
%#codegen
coder.varsize('a');
coder.varsize('b');
[~, ~, ~, a, ~, b] = kurtogram(x, sampRate);
% kurtogram(x, sampRate);
fc = a;
BW = b;
end

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeIntroduction to Installation and Licensing についてさらに検索

質問済み:

HF
2021 年 1 月 30 日

コメント済み:

HF
2021 年 1 月 31 日

Community Treasure Hunt

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

Start Hunting!

Translated by