how to convert file.m into block in Simulink ?
조회 수: 1 (최근 30일)
이전 댓글 표시
hi,
I wrote a function that produce 40 binary bits vector according to another 20 bits vector. In Matlab it works ok.
I want to convert it into a blockqmodel in Simulink.
Anybody knows how to do it ?
for example:
function gate_h = gate_array(I_H, indx_h)
no_cells = 20;
if(I_H > 0)
TMP_reg = [zeros(1, no_cells-indx_h), ones(1, indx_h)];
else
TMP_reg = [ones(1, indx_h), zeros(1, no_cells-indx_h)];
end
bitpatterns = {[0 1], [1 0]};
gate_h = cell2mat(bitpatterns(TMP_reg + 1));
Thanks, Henry
댓글 수: 0
채택된 답변
Walter Roberson
2016년 3월 4일
Try using the following as a MATLAB Function block
function gate_h = gate_array(I_H, indx_h)
no_cells = 20;
gate_h = zeros(1, no_cells * 2);
gate_h(1:2:indx_h*2) = 1;
gate_h(indx_h*2+1:2:no_cells*2-1) = 1;
if I_H > 0
gate_h = 1 - gate_h;
end
댓글 수: 5
추가 답변 (1개)
Rick Rosson
2016년 3월 4일
Have you tried using the MATLAB Function block? It's in the User Defined Functions sub-library in base Simulink.
참고 항목
카테고리
Help Center 및 File Exchange에서 Simulink Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!