Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

How to model in Simulink a matlab function to get every value from the loop?

1 vue (au cours des 30 derniers jours)
shmng
shmng le 11 Oct 2017
Clôturé : MATLAB Answer Bot le 20 Août 2021
Dear All, I have the following code which I would like to invoke from simulink as a Matlab function. // inc would be input from the model as a counter which increments
function y = fcn(inc)
SIZE = 250 ; // size of array near like LUT creation
AMPLITUDE = 32767;
t = 0:1:(SIZE);
sinetable = round(AMPLITUDE*sin(2*pi*t/SIZE));
ucTable = int16(sinetable.');
index = uint16(1);
for i = 1:8000
if(bitsra(index,8) >= SIZE)
index = uint16(1);
end
uOut= ucTable(bitsra(index,8)+ 1);
X(i) = uOut;
index = index + inc;
end
y = X';
I would like to output every single value (i.e. uOut) which forms a sine. I would like to have the functionality same as counter->LUT->output. I have attached a model to clarify the above function behavior.
Please help me through this. Is my approach correct?
Thanks in advance.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by