How to input a string in a function and then use the string original name
1 view (last 30 days)
Show older comments
Tarek Abdallah
on 10 Oct 2015
Commented: Tarek Abdallah
on 10 Oct 2015
Hello,
My need: I want to write a function, one of the inputs would be one of 20 text files. Then I want to plot the data inside the text file.
My problem: I can't find a way to write a function that loads a text file of my choice.
This is how I wrote the code that is not working, I greatly appreciate any help.
function []=MyText(TextFile)
text(1,:)=load('text123.txt') % text123 is the original file name. It was I will use to in the input when I run the function.
t=0:10;
plot(t,text)
0 Comments
Accepted Answer
Walter Roberson
on 10 Oct 2015
function []=MyText(TextFile)
text(1,:)=load(TextFile);
t=0:10;
plot(t,text)
More Answers (0)
See Also
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!