User Inputs String variable that is name of vector. want script to calculate on values of that vector
2 views (last 30 days)
Show older comments
Hello,
I know this is VERY BASIC, but I cannot find an answer in the books, Matlab Guide, or Matlab Central.
Need help with a script:
workspace has a lot of named variables
Request user input:
filename = input ('select a variable', 's');
now filename is a string
the name (string) in filename is associated with a vector of some 50K numbers
I want to analyze the vector whose name is in the string filename
How can I tell Matlab to calculate on the vector?
2 Comments
Walter Roberson
on 18 Feb 2013
What file format is the file in? Or what command would you use to load one of the files by name?
Answers (2)
Image Analyst
on 18 Feb 2013
Try this:
[baseFileName, folder] = uigetfile('*.*', 'Select a variable');
fullFileName = fullfile(folder, baseFileName)
Then use some code to read in "the vector" from your file. You can use a function such as csvread(), dlmread(), textscan(), fgetl(), or whatever works.
See Also
Categories
Find more on MATLAB Report Generator 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!