MATLAB Answers

Info

This question is closed. Reopen it to edit or answer.

ismember is not supported for fixed-point conversion

3 views (last 30 days)
Matlab
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.

  7 Comments

Show 4 older comments
Matlab
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[41]
* const boolean_T locs[41]
* boolean_T isOut[41]
* Return Type : void
*/
void ismember(const double Y[41], const boolean_T locs[41], boolean_T isOut
[41])
{
int k;
boolean_T y;
boolean_T exitg1;
int n;
boolean_T x[41];
int unusedExpr[41];
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
Adam Danz on 20 Mar 2020
I'm afraid I don't have enough experience with Matlab Coder to be of much assistance here.

Answers (0)

Community Treasure Hunt

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

Start Hunting!