MATLAB Answers

Integers can only be raised to positive integral powers in db2mag computation

19 views (last 30 days)
Jogger
Jogger on 8 Jan 2021
Commented: Jogger on 18 Jan 2021
I am converting matlab code to c using fixed point coder app
I am getting the below error
Input to function db2mag_conv
decibelTomag.u1 = 10
decibelTomag.u2 = [-90:0.1:90]
function [y] = db2mag_conv(decibelTomag)
y = power(decibelTomag.u1,double(decibelTomag.u2/20))
end
Error signature
### Begin Fixed Point Simulation using Scaled Doubles : db2mag_conv
Error using >intpower', 'C:/Program Files/MATLAB/R2020b/toolbox/eml/lib/matlab/ops/power.m', 187)">power>>intpower (line 187)
Integers can only be raised to positive integral powers
I need help in resolving the error

Answers (1)

Nitin Kapgate
Nitin Kapgate on 13 Jan 2021
You will need to cast both "decibelTomag.u1" and "decibelTomag.u2" as single type (Fixed Point Coder App doesn't support doubles) as follows:
y = power(single(decibelTomag.u1),single(decibelTomag.u2/20))
This should help in getting your problem resolved.
  4 Comments
Jogger
Jogger on 18 Jan 2021
Thanks steven, But stil the issue did not go away, can you please suggest another approach ?

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!