ユーザー定義函数をSimulink側で作る

下のような形で定義する。powerが返値、deltaHが引数。%はコメント。fcnが函数名ということか?

function power = fcn(deltaH)

Cp = 0.35; % Power coefficient
rho = 1000; % Density of water, kg/m^3
A = pi*10^2; % Area of turbine blade
g = 9.81; % Acceleration of gravity, m/s^2


% Replace the equation below with the correct equation for power
power = 0.5*Cp*rho*A*(2*g*abs(deltaH))^(3/2);

[power, v]が返値、deltaHが引数。

function [power ,v] = fcn(deltaH)

Cp = 0.35; % Power coefficient
rho = 1000; % Density of water, kg/m^3
A = pi*10^2; % Area of turbine blade
g = 9.81; % Acceleration of gravity, m/s^2


% Replace the equation below with the correct equation for power
power = 0.5*Cp*rho*A*(2*g*abs(deltaH))^(3/2);
v = sqrt(2*g*abs(deltaH));