Info

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

How do I do this data conversion in both Matlab and Simulink?

1 view (last 30 days)
I need some help with converting a variable in matlab to fixed point.
I have a variable that should start from 0 and step up in increments of 0.03 to at least 300, preferably even higher than that. I also want it to take up as little resources as possible. I have tried:
x=fi(0,0,16,0.03,0,'SumMode','SpecifyPrecision','SumWordLength',28,'SumFractionLength',19);
y = fi(0.03,0,16,0.03,0,'SumMode','SpecifyPrecision','SumWordLength',28,'SumFractionlength',19);
and then looping:
x = x + y;
Then I get to 300 in 10,000 steps which is what I want. But as you can see I need a SumWordLength of 28 to achieve this...
I have som trouble to achieve this conversion in a simlink data conversion block too. Does anyone know of a way to make the variable a bit more 'lean' but still be able to convert to the same format using a simulink data conversion block?

Answers (0)

Community Treasure Hunt

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

Start Hunting!