0

I want to make a function that can take a matrix element as an input. Is this possible? I have in the main script a matrix like:

A = [0 1 2 3 4 5 6 7 8] 

I want to make a function that is like:

function [a] = myFunction(b, A(7))
a = b + A(7)

Is this possible? The error is that I have unbalanced parenthesis or brackets so I guess it doesn't like the A(7) on the input.

Any ideas? Thank you.

1 Answer 1

3

To do that you simply need to declare your function as you normally would

function [a] = myFunction(b, c)
a = b + c;

and provide A(7) as an input: result=myFunction(b,A(7));.

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

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.