Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab input string as variable name (or other ways)

  1. Feb 21, 2012 #1

    I am writing a Matlab function(script), which take some input.

    I have several datasets in the workspace, say dataset1,dataset2,dataset3, ect

    In my function, I have tried to use

    data = input('Please input your dataset', 's')

    and then use 'data' as a variable for some computation, say


    It does not work. I wonder what's the 'correct' way to do it?


    OR, I can add an argument in myfunction, say

    function y = myf(ds,para)

    use 'ds' to indicate the dataset that i want to use.

    However, in this case, how should i use 'fminsearch' for optimization?
    'fminsearch' will then treat this 'ds' input as a parameter.


  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?