Use a Script file as the input to a function
Mostra commenti meno recenti
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 Commento
Stephen23
il 3 Set 2016
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
Risposte (0)
Categorie
Scopri di più su File Operations in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!