# ismember is not supported for fixed-point conversion

5 views (last 30 days)
Matlab on 18 Mar 2020
Closed: Matlab on 22 Mar 2020
I am coverting the floating point to fixed point using Matlab coder
Below is code
function isOut = Verify_ismember_data()
Y = 51;
locs = 4;
isOut = ismember(1:Y,locs); % I tried isOut = all(ismember(Y,locs)) & intersect- this does not help
plot(isOut,'b-x','Linewidth',2);
ismember is not supported for fixed-point conversion.

Matlab on 20 Mar 2020
Thanks! Below is the ismember in c routine. Don't know why it's marked as spam
/* Include Files */
#include "ismember.h"
#include "sort.h"
/* Function Definitions */
/*
* isOut = intersect(1:size(Y,1), locs);
* Arguments : const double Y
* const boolean_T locs
* boolean_T isOut
* Return Type : void
*/
void ismember(const double Y, const boolean_T locs, boolean_T isOut
)
{
int k;
boolean_T y;
boolean_T exitg1;
int n;
boolean_T x;
int unusedExpr;
int ilo;
int imid;
(void)Y;
for (k = 0; k < 41; k++) {
isOut[k] = false;
}
y = true;
k = 0;
exitg1 = false;
while ((!exitg1) && (k < 40)) {
y = (((int)locs[k] <= (int)locs[k + 1]) && y);
if (!y) {
exitg1 = true;
} else {
k++;
}
}
if (!y) {
for (k = 0; k < 41; k++) {
x[k] = locs[k];
}
sort(x, unusedExpr);
for (k = 0; k < 41; k++) {
n = 0;
ilo = 1;
exitg1 = false;
while ((!exitg1) && (41 >= ilo)) {
imid = (ilo >> 1) + 19;
if ((ilo & 1) == 1) {
imid++;
}
if (k + 1 == x[imid]) {
n = imid + 1;
exitg1 = true;
} else {
ilo = imid + 2;
}
}
if (n > 0) {
while ((n - 1 > 0) && (k + 1 == x[n - 2])) {
n--;
}
}
if (n > 0) {
isOut[k] = true;
}
}
} else {
for (k = 0; k < 41; k++) {
n = 0;
ilo = 1;
exitg1 = false;
while ((!exitg1) && (41 >= ilo)) {
imid = (ilo >> 1) + 19;
if ((ilo & 1) == 1) {
imid++;
}
if (k + 1 == locs[imid]) {
n = imid + 1;
exitg1 = true;
} else {
ilo = imid + 2;
}
}
if (n > 0) {
while ((n - 1 > 0) && (k + 1 == locs[n - 2])) {
n--;
}
}
if (n > 0) {
isOut[k] = true;
}
}
}
}
Adam Danz on 20 Mar 2020
I'm afraid I don't have enough experience with Matlab Coder to be of much assistance here.
Matlab on 22 Mar 2020
No worries. Thanks a lot for your help.