Error in fi divide for embedded fi object
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
0 votes
Share a link to this question
For fi objects, B must be a scalar in A/B.
Error in / (line 23)
c = fidivide(a,b);
Accepted Answer
3 votes
15 Comments
- Are you trying to do code generation? This error only occurs during code generation.
- You have defined the variable power to be floating-point double. Do you want the code to be purely fixed-point?
- Do you want to generate C code? or a MEX function to simulate in MATLAB?
- The range of the magnitude of the output is between
and
. This means that you need at least 30 integer bits, and 30 fractional bits in the output. The output is also positive and negative. To accomodate this, I chose a signed fixed-point type with a 64 bit word length and 32 bit fraction length. - You can see in the generated code that the large word length of the output means that multiple words of builtin C types were needed for intermediate products and sums.
- I changed the names of the variables from base, exp, power to b, e, p respectively so the builtin functions of the same name would not be overloaded.
- I separated out the functions that you want to generate code for from the test bench.
- The test bench compiles and runs fixed-point as a MATLAB Executable (MEX).
- The test bench also generates C code for the fixed-point function.
- Run MATLAB script test_bench to test and compile the code.
- Save each of the functions enclosed below in their own file.
- Debugging data for your reference
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Tags
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!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)