MATLAB: How to input a string in a function and then use the string original name

matlab functionstring in function

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)

Best Answer

function []=MyText(TextFile)
text(1,:)=load(TextFile);
t=0:10;
plot(t,text)