# Use a Matlab script as limit-state function

In one of the previous posts, we showed you how to work with in-line Matlab functions directly in STRUREL. Did you know? You can also use a Matlab script as limit-state function in STRUREL.

Again, we use the example limit-state function RS that we already used in the past: Our stochastic model consists of the two random variables R and S, where R represents the resistance of a system of interest and S is the system load. The symbolic expression for the corresponding limit-state function in the native syntax of STRUREL would be:

`FLIM(1) = R-S`

However, if you have Matlab installed on your system and if the Matlab interface of STRUREL is configured correctly, you could also use the following expression:

`FLIM(1) = matlabs("my_model")`

where `my_model.m` is a Matlab script file located in the same directory as the iti-file of STRUREL.

For the example at hand, the Matlab script file should look as follows:

`function [lsfval] = my_model(INPUT)R = INPUT(1);S = INPUT(2);lsfval = R - Send`

The ordering of the random variables in the vector `INPUT` corresponds to the order in which they appear in the stochastic model of STRUREL.

Alternatively, the Matlab script file could look as follows:

`function [lsfval] = my_model(INPUT)global R;global S;lsfval = R - Send`

where the variable names R and S must match the names of the random variables of the stochastic model of STRUREL.

By means of the STRUREL command `matlabs`, you can integrate any limit-state function written in Matlab-Syntax directly in your reliability analysis performed with STRUREL.

# How to use in-line Matlab in Strurel

In the last post, we showed you how to work with in-line Python functions directly in STRUREL. Did you know? You can also use in-line Matlab functions directly in a symbolic expression in STRUREL.

For example, assume a problem for which you have the two random variables R and S in your stochastic model, where R represents the resistance of a system of interest and S is the system load. The symbolic expression for the corresponding limit-state function in the native syntax of STRUREL would be:

`FLIM(1) = R-S`

However, if you have Matlab installed on your system and if the Matlab interface of STRUREL is configured correctly, you could also use the following expression:

`FLIM(1) = matlabf("R-S")`

Sure, calling the Matlab interpreter for this simple demonstration example is like taking a sledgehammer to crack a nut. However, the interface-function `matlabf` is a tool that gives you access to the full power of Matlab directly in the symbolic expression of STRUREL.

# How to use in-line Python in Strurel

Did you know? You can use in-line Python functions directly in a symbolic expression in STRUREL.

For example, assume a problem for which you have the two random variables R and S in your stochastic model, where R represents the resistance of a system of interest and S is the system load. The symbolic expression for the corresponding limit-state function in the native syntax of STRUREL would be:

`FLIM(1) = R-S`

However, if you have Python installed on your system and if the Python interface of Strurel is configured correctly, you could also use the following expression:

`FLIM(1) = pythonf("R-S")`

Sure, calling the Python interpreter for this simple demonstration example is like taking a sledgehammer to crack a nut. However, the interface-function `pythonf` is a tool that gives you access to the full power of Python directly in the symbolic expression of Strurel.

# Final Reminder: Short Course in December

There is still a small number of seats available for our short course on ‘Uncertainty and Reliability in Engineering’, which takes place in Munich on December 2 to 3.

The course fee includes a 1-hour consulting session!

Registration and program: https://eracons.com/short-course

# Short Course

Once more, we organize a short course on ‘Uncertainty and Reliability in Engineering’. It will take place in Munich on December 2 to 3.

As a participant, you get a free consulting session with us on a problem of your choice.

Registration and program: https://www.eracons.com/short-course