0

For some reason I need to use workspace variables within a function. How can I "import" these variables into my function? Thanks

2
  • 3
    Share your code. Are you asking how to pass values as arguments to a function? Commented Jun 5, 2018 at 17:45
  • 1
    Please read "Function Basics" in the MATLAB documentation. Commented Jun 5, 2018 at 21:06

2 Answers 2

1

Either pass the variables by argument or (and only seldom recommended) use global variables

Sign up to request clarification or add additional context in comments.

Comments

1

You can use evalin('caller', ...) or evalin('base', ...) to do this, but it is vastly preferable to pass arguments in explicitly.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.