Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

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

1 Ansicht (letzte 30 Tage)
shmng
shmng am 11 Okt. 2017
Geschlossen: MATLAB Answer Bot am 20 Aug. 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.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by