Why cant I use a custom MATLAB function in Simscape equation section?

6 ビュー (過去 30 日間)
Julian Ulrich
Julian Ulrich 2021 年 8 月 25 日
回答済み: Abhishek 2025 年 7 月 1 日
component fou_bv_elem
nodes
p = fouriernet.FourierNet; % +:left
n = fouriernet.FourierNet; % -:right
end
parameters
R = { 8.314, 'J/mol/K'};
F = { 96485, 'A*s/mol'};
T = { 298, 'K'};
i_bv = { 0.8734, 'A'};
alpha_a = 0.5;
alpha_k = 0.5;
end
variables(Access=private)
fU = { zeros(1,p.numb), 'V' }; % Voltage
fI = { zeros(1,p.numb), 'A' }; % Current
end
branches
fI : p.fI -> n.fI;
end
equations
fU == p.fU - n.fU;
fI == fouriernet.computeCurrent(fU,p.numb,R,F,T,i_bv,alpha_a,alpha_k); %I want to use this function
end
end

回答 (1 件)

Abhishek
Abhishek 2025 年 7 月 1 日
To use custom MATLAB function in ‘Simscape’, there are two available approaches, depending on whether the function is defined as a main or local function:
  • Main function: Create a separate ‘.ssc’ file with the same name as the function. This file can then be called within the custom block definition.
  • Local function: Define the function after the final ‘end’ keyword in the main function file which is then accessible only within the scope of that specific file.
For detailed examples and further information, refer to the MATLAB documentation below:

カテゴリ

Help Center および File ExchangeFoundation and Custom Domains についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by