Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

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

조회 수: 2 (최근 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