sscnewfile
必須のキーワードとよく使用されるキーワードが取り込まれた新しい Simscape ファイルを作成する
説明
sscnewfile( は、既定のコンポーネント テンプレートを使用して、指定した名前 name)name のコンポーネントを作成します。この関数は、新しい Simscape™ ファイル name を現在のフォルダーに自動的に保存します。
sscnewfile( は、name,template_keyword)template_keyword で指定したドメイン固有のテンプレートを使用して、指定した名前 name のコンポーネントを作成します。使用可能なキーワードのリストを表示するには、-list オプションを使用します。この関数は、新しい Simscape ファイル name を現在のフォルダーに自動的に保存します。
sscnewfile( は、テンプレートとして同じタイプのファイル name,template_file)template_file を使用し、指定した名前 name のコンポーネント、ドメイン、または関数のファイルを作成します。テンプレート ファイル名には、ファイル パスを含める必要があります。simscape.template 名前空間にはさまざまなテンプレート ファイルが用意されていますが、任意の Simscape ファイルをテンプレートとして使用することができます。関数は、テンプレート ファイルの内容を新しいファイルにコピーし、コンポーネント、ドメイン、または関数の名前を name に置き換えて、新しいファイルを現在のフォルダーに保存します。
sscnewfile -list は、使用可能なテンプレート キーワードのリストを返し、simscape.template 名前空間で使用可能なすべてのファイルをリストします。
例
既定のコンポーネント テンプレートを使用して MyComponent という名前のコンポーネントを作成し、現在のフォルダーに MyComponent.ssc という名前で保存します。
sscnewfile('MyComponent')新しいファイルが MATLAB® エディターで開きます。
component MyComponent
% Simple Simscape component
parameters
% Add parameters here
% p = { value , 'unit' }; % Parameter name
end
nodes
% A = namespace_name.domain_name; % A:left
% B = namespace_name.domain_name; % B:right
end
variables
% x = { value , 'unit' }; % Through variable name
% y = { value , 'unit' }; % Across variable name
end
branches
% x : A.x -> B.x;
end
equations
% Add equations here
% y == A.y - B.y;
% x == fcn(y);
end
end新しいコンポーネントを作成する際の開始点としてこのファイルを使用します。% で始まる行はコメントです。必要に応じて、実際の宣言や方程式に置き換えます。不要なセクションを削除したり、components、connections、intermediates などの他のセクションを追加したりすることもできます。
電気ドメイン用の既定のコンポーネント テンプレートを使用して MyResistor という名前のコンポーネントを作成し、現在のフォルダーに MyResistor.ssc という名前で保存します。
sscnewfile('MyResistor','electrical')
新しいファイルが MATLAB エディターで開きます。
component MyResistor
% Two-port electrical component
parameters
% Add parameters here
% R = { 1, 'Ohm' }; % Resistance
end
nodes
p = foundation.electrical.electrical; % +:left
n = foundation.electrical.electrical; % -:right
end
variables
i = { 0, 'A' }; % Current
v = { 0, 'V' }; % Voltage
end
branches
i : p.i -> n.i;
end
equations
% Voltage difference between nodes
v == p.v - n.v;
% Add equations here
% v == i*R;
end
end新しいコンポーネントを作成する際の開始点としてこのファイルを使用します。% で始まる行はコメントです。必要に応じて、実際の宣言や方程式に置き換えます。カスタム抵抗を作成する例については、Simscape 言語での線形抵抗のモデル化を参照してください。
Foundation 気体ドメインをテンプレートとして使用して MyGasDomain という名前のドメインを作成し、現在のフォルダーに MyGasDomain.ssc という名前で保存します。
sscnewfile('MyGasDomain', 'foundation.gas.gas')
新しいファイルが MATLAB エディターで開きます。新しいドメインの名前は MyGasDomain で、これは name 引数と一致しています。ファイルの残りの部分は、Foundation 気体ドメインの定義のコピーです。
新しいドメインを作成する際の開始点としてこのファイルを使用します。アプリケーションに合わせて、ドメインのパラメーターやプロパティを変更します。
テンプレート キーワードと、simscape.template 名前空間で使用可能なテンプレート ファイルをリストします。
sscnewfile -list--------------------------------------------------------------------------
Template keywords
---------------------------------------------------------------------------------------
angle_based_rotational simscape.template.rotational.two_port
default simscape.template.simple_component
electrical simscape.template.electrical.two_port
gas simscape.template.gas.two_port_steady
magnetic simscape.template.magnetic.two_port
moist_air simscape.template.moist_air.two_port_steady
position_based_translational simscape.template.translational.two_port
rotational simscape.template.mechanical.rotational.two_port
signal simscape.template.signal.simple_component
thermal simscape.template.thermal.two_port
thermal_liquid simscape.template.thermal_liquid.two_port_steady
translational simscape.template.mechanical.translational.two_port
two_phase_fluid simscape.template.two_phase_fluid.two_port_steady
-------------------------------------------------
Files in namespace simscape.template
-------------------------------------------------
simple_component Simple Simscape component
simple_function
-----------------------------------------------
Files in namespace simscape.template.electrical
-----------------------------------------------
two_port Two-port electrical component
------------------------------------------------------
Files in namespace simscape.template.gas
------------------------------------------------------
two_port_dynamic Two-port dynamic gas component
two_port_steady Two-port steady gas component
---------------------------------------------
Files in namespace simscape.template.magnetic
---------------------------------------------
two_port Two-port magnetic component
----------------------------------------------------------
Files in namespace simscape.template.mechanical.rotational
----------------------------------------------------------
two_port Two-port rotational component
-------------------------------------------------------------
Files in namespace simscape.template.mechanical.translational
-------------------------------------------------------------
two_port Two-port translational component
------------------------------------------------------------
Files in namespace simscape.template.moist_air
------------------------------------------------------------
two_port_dynamic Two-port dynamic moist_air component
two_port_steady Two-port steady moist air component
---------------------------------------------------------
Files in namespace simscape.template.rotational
---------------------------------------------------------
two_port Two-port angle-based rotational component
--------------------------------------------------------------
Files in namespace simscape.template.signal
--------------------------------------------------------------
simple_component Simple component with physical signals
--------------------------------------------
Files in namespace simscape.template.thermal
--------------------------------------------
two_port Two-port thermal component
-----------------------------------------------------------------
Files in namespace simscape.template.thermal_liquid
-----------------------------------------------------------------
two_port_dynamic Two-port dynamic thermal liquid component
two_port_steady Two-port steady thermal liquid component
---------------------------------------------------------------
Files in namespace simscape.template.translational
---------------------------------------------------------------
two_port Two-port position-based translational component
------------------------------------------------------------------
Files in namespace simscape.template.two_phase_fluid
------------------------------------------------------------------
two_port_dynamic Two-port dynamic two-phase fluid component
two_port_steady Two-port steady two-phase fluid componentこれらのファイルのいずれかを新しいコンポーネントのテンプレートとして使用するには、2 番目の入力引数としてファイルの絶対パスと名前 (たとえば、'simscape.template.gas.two_port_dynamic') を指定します。
入力引数
新しいコンポーネント、ドメイン、または関数の名前。文字ベクトルまたは string スカラーとして指定します。この名前は、作成される新しい Simscape ファイルの名前としても使用されます。ファイルは現在のフォルダーに自動的に保存されます。
例: 'MyResistor'
データ型: char | string
新しいファイルのテンプレートとして使用するコンポーネント ファイルのタイプ。文字ベクトルまたは string スカラーとして指定します。これらのキーワードを使用して、特定のドメイン タイプのコンポーネント ファイルを作成します。使用可能なキーワードのリストを表示するには、-list オプションを使用します。
例: 'electrical'
データ型: char | string
Simscape のコンポーネント、ドメイン、または関数の名前。文字ベクトルまたは string スカラーとして指定します。ファイル名には、最上位の名前空間フォルダーからのファイルのパスを含める必要があります。ファイルが MATLAB パス上にある場合は、代わりに絶対ファイル パスを指定することもできます。作成される新しいファイルでは、この Simscape ファイルがテンプレートとして使用されます。
例: 'foundation.electrical.elements.resistor'
データ型: char | string
バージョン履歴
R2019b で導入
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)