- the simplest but dangerous way is to name the data in your workspace the same as your variables in your function and run it as a script (line by line).
- the methodic way is to edit run configurations for the function (next to the green play icon)
- the most straightforward is to call the function after you saved it.
get data from workspace
2 views (last 30 days)
Show older comments
I have some data in the workspace currently. Now i am writing a m function which needs these data. How can I get it? it always show that undefined coefficient.
0 Comments
Answers (1)
Oleg Komarov
on 19 Feb 2012
A "standard" function could be considered a black box where you throw data in and get something out of it.
Once you defined the mechanism of the black box, you give it some data:
foo([1 2 3])
ans =
3
If you need the data to test your function there are several ways of doing that:
If you have to use that specific data all the time, then hardcode it.
Evalin can throw variables in your function workspace from the base workspace. I never used the function except from educational purposes and I discourage you to do so.
Else, is hard to imagine what you're trying to accomplish w/o additional details.
0 Comments
See Also
Categories
Find more on Scope Variables and Generate Names 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!