Info

此问题已关闭。 请重新打开它进行编辑或回答。

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

2 次查看(过去 30 天)
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.

回答(0 个)

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by