- 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!