How to use User Defined Function in Simulink ?

조회 수: 2 (최근 30일)
Sadi Altamimi
Sadi Altamimi 2012년 4월 27일
Hello everyone;
I have a problem using User Defined Blocks in simulink. I have a simple MATLAB code and I want to create a block in simulink that do the job I specified.
The code defines a DiBit Encoder, that accepts a binary stream of bits, and produce two outupts (I and Q). Where I is the bits in stream with odd index number, and Q is the stream of bits in the sequence with even index number.
Here is the code:
function [I,Q] = DiBit_Encoder(x)
sizeX = length(x)/2;
y = reshape(x, 2, sizeX);
I = y(1, 1:end);
Q = y(2, 1:end);
end
How, and where, should I put this code in simulink blocks? What is the block name ? and if there is some needed editing on the code please tell me!
Regards.

답변 (1개)

TAB
TAB 2012년 4월 27일
You can place yor MATLAB code into User-Defined functions/Embedded MATLAB Function function block. Go through its help doc to know how to use it.
  댓글 수: 1
Sadi Altamimi
Sadi Altamimi 2012년 4월 27일
I try that, and I face problems ..
So I need step by step instruction :)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interactive Model Editing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by