From: Dan Thatcher on 29 Jun 2010 11:04 Hi everyone, How can I use imported data in a function? I have the data I need in the workspace which works perfectly when I run the code as a script, but when I put a function around it, it cannot find the data. The error seems quite straight forward: ??? Undefined function or method 'data' for input arguments of type 'double'. I need the code in a function to insert it into another function and I cannot use xlsread as it does not seem to work on this version of Matlab on mac's. Any hints?
From: Andy on 29 Jun 2010 11:13 "Dan Thatcher" <d.thatcher85(a)gmail.com> wrote in message <i0d215$ahe$1(a)fred.mathworks.com>... > Hi everyone, > > How can I use imported data in a function? I have the data I need in the workspace which works perfectly when I run the code as a script, but when I put a function around it, it cannot find the data. The error seems quite straight forward: > > ??? Undefined function or method 'data' for input > arguments of type 'double'. > > > I need the code in a function to insert it into another function and I cannot use xlsread as it does not seem to work on this version of Matlab on mac's. Any hints? If this function needs certain data to run, then you should probably pass that data to the function as an argument.
From: Dan Thatcher on 4 Jul 2010 06:55 > If this function needs certain data to run, then you should probably pass that data to the function as an argument. Thanks Andy, I solved the problem loading the data as a '.mat' file then setting global variables. Cheers!
From: darthshak on 4 Jul 2010 05:34 You can try using the evalin function. If foo is the name of the variable in the workspace, foo = evalin('base','foo'); would load the variable foo into the function workspace.
From: us on 4 Jul 2010 10:38 "Dan Thatcher" <d.thatcher85(a)gmail.com> wrote in message <i0ppar$jtf$1(a)fred.mathworks.com>... > > > If this function needs certain data to run, then you should probably pass that data to the function as an argument. > > Thanks Andy, > > I solved the problem loading the data as a '.mat' file then setting global variables. Cheers! well... clearly not an experienced MLbber... http://matlabwiki.mathworks.com/MATLAB_FAQ#Why_are_global_variables_bad.3F us
|
Next
|
Last
Pages: 1 2 Prev: basic communication modeling question..performance is strange Next: Filtering |