Info
This question is closed. Reopen it to edit or answer.
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
ismember is not supported for fixed-point conversion
2 views (last 30 days)
Show older comments
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
Guillaume
on 18 Mar 2020
I don't see where fixed point is used in your code snippet.
I don't have the fixed-point toolbox and I've never used fixed-point in matlab (but have in other contexts). If ismember doesn't support fixed-point numbers can't you just compare the underlying integer representation with ismember instead. This assumes that the fixed point numbers you want to compare have the same precision of course.
Adam Danz
on 18 Mar 2020
Edited: Adam Danz
on 19 Mar 2020
The function doesn't have any inputs and I don't see any fixed point values. If the error is unexpected, make sure you're not shadowing the ismember function.
which ismember -all
% C:\Program Files\MATLAB\R2019b\toolbox\matlab\ops\ismember.m Example output, 1st row
Life is Wonderful
on 19 Mar 2020
Edited: Life is Wonderful
on 20 Mar 2020
Thanks a lot for all the inputs.
I am using c code generation for the ismember matlab function. For this ,I use MATLAB Coder™ [ Use to generate C code from Matlab code].
We get Matlab code from the APPS ( Toolbar ribbon , HOME,PLOTS,APPS,EDITOR,PUBLISH,VIEW)
Irrespctive of fixed data or floating data vector, ismember for Fixed point converter throws error "ismember is not supported for fixed-point conversion"
The function doesn't have any inputs and I don't see any fixed point values
I can think of somethiing like below , You have pks as floating values and locs as fixed values
function isOut = Verify_ismember_data(pks,locs)
isOut = ismember(1:size(pks),locs);
The requirement was derived from below data(
locs | pks |
----------+----------+
2 | 0.0102 |
3 | 0.0096 |
4 | 0.0058 |
5 | 0.0044 |
9 | 0.0036 |
12 | 0.006 |
13 | 0.0088 |
14 | 0.0044 |
15 | 0.0045 |
16 | 0.0068 |
17 | 0.0078 |
18 | 0.0033 |
21 | 0.9989 | *Peaks & locs
23 | 0.0036 |
24 | 0.0077 |
25 | 0.008 |
31 | 0.0048 |
32 | 0.006 |
35 | 0.0061 |
36 | 0.0037 |
39 | 0.0059 |
40 | 0.0124 |
41 | 0.0123 |
isOut = ismember(1:size(Y),locs);
K>> class(locs)
ans =
'double'
K>> class(Y)
ans =
'double'
isOut = ismember(1:size(Y,1), locs);
I don't have the fixed-point toolbox and I've never used fixed-point in matlab (but have in other contexts)
This is generic or you have some other ideas for converting the Matlab function into C ( floating to fixed point), I would like to know , please share it.
Please find the ismember
K>> pwd
ans =
'C:\Users\Release_version\Audio\Sandbox'
K>> which ismember -all
C:\Program Files\MATLAB\R2019b\toolbox\matlab\ops\ismember.m
C:\Program Files\MATLAB\R2019b\toolbox\matlab\ops\@cell\ismember.m % Shadowed cell method
C:\Program Files\MATLAB\R2019b\toolbox\matlab\codetools\@mtree\ismember.m % Shadowed mtree method
C:\Program Files\MATLAB\R2019b\toolbox\matlab\timefun\@datetime\ismember.m % Shadowed datetime method
C:\Program Files\MATLAB\R2019b\toolbox\matlab\timefun\@duration\ismember.m % Shadowed duration method
ismember is a built-in method % Shadowed mtree.Type method
ismember is a built-in method % Shadowed connector.internal.LoggerLevel method
ismember is a built-in method % Shadowed connector.internal.PromiseState method
ismember is a built-in method % Shadowed matlab.graphics.controls.internal.ToolbarValidator method
ismember is a built-in method % Shadowed matlab.lang.OnOffSwitchState method
ismember is a built-in method % Shadowed matlab.graphics.shape.internal.util.PointDataTipStyle method
ismember is a built-in method % Shadowed matlab.graphics.shape.internal.util.PinnableStyle method
ismember is a built-in method % Shadowed codertarget.targethardware.BaseProductID method
ismember is a built-in method % Shadowed codergui.ReportServices method
ismember is a built-in method % Shadowed coder.internal.gui.Features method
ismember is a built-in method % Shadowed coder.make.enum.BuildArtifact method
ismember is a built-in method % Shadowed coder.make.enum.BuildOutput method
ismember is a built-in method % Shadowed coder.descriptor.AutosarExpressionMode method
ismember is a built-in method % Shadowed coder.descriptor.AutosarParameterAccessMode method
ismember is a built-in method % Shadowed coder.descriptor.CoderGroupImplementation method
ismember is a built-in method % Shadowed coder.descriptor.EndianessEnum method
ismember is a built-in method % Shadowed coder.descriptor.IOAccessModes method
ismember is a built-in method % Shadowed coder.descriptor.IntDivRoundToEnum method
ismember is a built-in method % Shadowed coder.descriptor.LUTObjectStructOrderExplicitValues method
ismember is a built-in method % Shadowed coder.descriptor.ModelSelfCategoryEnum method
ismember is a built-in method % Shadowed coder.descriptor.TaskingModes method
ismember is a built-in method % Shadowed coder.descriptor.TimingModes method
ismember is a built-in method % Shadowed coder.descriptor.types.DataStoreKind method
ismember is a built-in method % Shadowed coder.descriptor.types.IOTypes method
ismember is a built-in method % Shadowed coder.descriptor.mem.AutosarExpressionMode method
ismember is a built-in method % Shadowed coder.descriptor.mem.AutosarParameterAccessMode method
ismember is a built-in method % Shadowed coder.descriptor.mem.CoderGroupImplementation method
ismember is a built-in method % Shadowed coder.descriptor.mem.EndianessEnum method
ismember is a built-in method % Shadowed coder.descriptor.mem.IOAccessModes method
ismember is a built-in method % Shadowed coder.descriptor.mem.IntDivRoundToEnum method
ismember is a built-in method % Shadowed coder.descriptor.mem.LUTObjectStructOrderExplicitValues method
ismember is a built-in method % Shadowed coder.descriptor.mem.ModelSelfCategoryEnum method
ismember is a built-in method % Shadowed coder.descriptor.mem.TaskingModes method
ismember is a built-in method % Shadowed coder.descriptor.mem.TimingModes method
ismember is a built-in method % Shadowed coder.descriptor.mem.types.DataStoreKind method
ismember is a built-in method % Shadowed coder.descriptor.mem.types.IOTypes method
ismember is a built-in method % Shadowed coder.internal.BuildMode method
C:\Program Files\MATLAB\R2019b\toolbox\matlab\datatypes\@tabular\ismember.m % Shadowed tabular method
C:\Program Files\MATLAB\R2019b\toolbox\matlab\datatypes\categorical\@categorical\ismember.m % Shadowed categorical method
C:\Program Files\MATLAB\R2019b\toolbox\matlab\bigdata\@tall\ismember.m % Shadowed tall method
C:\Program Files\MATLAB\R2019b\toolbox\mbc\mbc\@guidarray\ismember.m % Shadowed guidarray method
C:\Program Files\MATLAB\R2019b\toolbox\mbc\mbc\@xregpointer\ismember.m % Shadowed xregpointer method
C:\Program Files\MATLAB\R2019b\toolbox\mbc\mbcdata\@cgprojconnections\ismember.m % Shadowed cgprojconnections method
C:\Program Files\MATLAB\R2019b\toolbox\parallel\gpu\@gpuArray\ismember.m % Shadowed gpuArray method
C:\Program Files\MATLAB\R2019b\toolbox\shared\statslib\@dataset\ismember.m % Shadowed dataset method
C:\Program Files\MATLAB\R2019b\toolbox\symbolic\symbolic\@sym\ismember.m % Shadowed sym method
Thank you!
Guillaume
on 19 Mar 2020
"This is generic or you have some other ideas for converting the Matlab function into C "
If it's matlab automatically converting your double variables to fixed point I can't help you.
However, if it's your own code where you've defined the fixed-point format and variables yourself, then my suggestion is to temporarily convert the fixed-point values to their underlying integer type (a basic cast in C) and to call ismember on the integers.
Life is Wonderful
on 20 Mar 2020
Edited: Life is Wonderful
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
on 20 Mar 2020
I'm afraid I don't have enough experience with Matlab Coder to be of much assistance here.
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)