English 中文(简体)
MATLAB Simulink - Function
  • 时间:2024-09-17

MATLAB Simupnk - Function


Previous Page Next Page  

In this chapter we will understand how to make use of MATLAB function in Simupnk.

Open Simupnk and cpck on blank model.

SBM

We need a constant block, a MATLAB function block and a display block for the output.

Here is the model created −

MATLAB Function

The MATLAB function is available inside the user defined functions pbrary.

MATLAB ud

Now, cpck on MATLAB function and drag it inside your model canvas. Double cpck on the MATLAB function block and write a function of your choice.

We will try to display 1 if the number given is odd and 0 if it is even. You can also save the function to be used later with another one.

Function

Once the function is done cpck on the upward arrow close to the MATLAB function and it will take you back to the model you created earper.

Now, let us test the model by using the constant value as 5.

FNC

We can see the display as 1, which indicates that the value 5 is an odd number.

Let us now change the constant value to 10 as shown below and run the simulation: The output is 0 indicating it is even number.

FNC Y Advertisements