mustBeFolder
説明
例
フォルダー内での実行
関数 mustBeFolder
を使用して、関数に渡されるフォルダー パスが有効なフォルダーであることを確認し、関数本体内の有効なフォルダーをテストするために条件文が使用されるのを回避します。
関数 runInFolder
は、指定されたフォルダーで関数を実行するように変更する前に、そのフォルダーが有効であることを確認します。
function r = runInFolder(path) arguments path {mustBeFolder} end orgFolder = cd(path); r = myFunct; cd(orgFolder) end
無効なフォルダー名を入力として渡すとエラーになります。
r = runInFolder("myFunct.m");
Error using runInFolder r = runInFolder("myFunct.m"); ↑ Invalid argument at position 1. The following folders do not exist: 'myFunct.m'.
入力引数
path
— フォルダーへのパス
string スカラー | 文字ベクトル
1 つ以上のフォルダーへのパス。string スカラー、文字ベクトル、string 配列、または文字ベクトルの cell 配列として指定します。
例: "H:\myfolder\mysubfolder"
データ型: char
| string
ヒント
mustBeFolder
は、プロパティと関数の引数の検証で使用されるように設計されています。
拡張機能
C/C++ コード生成
MATLAB® Coder™ を使用して C および C++ コードを生成します。
バージョン履歴
R2020b で導入
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)