Info

この質問は閉じられています。 編集または回答するには再度開いてください。

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

1 回表示 (過去 30 日間)
shmng
shmng 2017 年 10 月 11 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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