Use a Script file as the input to a function
古いコメントを表示
Hello, I am looking to make a function file that accepts any .m script file as an input.
Here is an example of the code I am trying fix to do this. I want the input to be the file X.m
function Untitled( X.m )
% find the correct directory and file
io_contents = ...
fullfile('New Folder', 'X.m');
% read the file
filetext = fileread(io_contents);
end
I am relatively new to using MATLAB in this fashion. Any help would be appreciated!
1 件のコメント
Stephen23
2016 年 9 月 3 日
It is not clear what you intend to do with this input, since it does not appear anywhere in the body of your function.
If you actually just want to be able to select the name of the fucntion via an input, then do this:
function Untitled(name)
io_file = fullfile('New Folder',name);
filetext = fileread(io_file);
end
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で File Operations についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!