Creating C code from matlab with changing data input size.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi all
I wrote a simple program.
function y = test(x) %#codegen
y = x+2;
end
Now I want to create c code and I need to define the type and the length of x. I define x as type double and length of 10;
void test(const real_T x[10], real_T y[10])
{
int32_T i0;
for (i0 = 0; i0 < 10; i0++)
{
y[i0] = x[i0] + 2.0;
}
}
The C code is OK!
How can it work in a case that the length of x is changing ?
Thx
0 Kommentare
Antworten (2)
Kaustubha Govind
am 21 Aug. 2012
I think you need to specify the type of the input using:
>> codegen test -args {coder.typeof(double(0), [1 Inf])}
zohar
am 22 Aug. 2012
1 Kommentar
Kaustubha Govind
am 22 Aug. 2012
Great! Thanks for posting your solution! It is likely that my solution will work in newer versions, but I'm not sure.
Siehe auch
Kategorien
Mehr zu MATLAB Coder finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!