- 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
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Oleg Komarov
2012 年 2 月 19 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Scope Variables and Generate Names についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!