Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想制作一个可以将矩阵元素作为输入的函数。这可能吗?我在主脚本中有一个矩阵,如:
A = [0 1 2 3 4 5 6 7 8]
我想做一个类似的功能:
function [a] = myFunction(b, A(7)) a = b + A(7)
这可能吗?错误是我有不平衡的括号或方括号,所以我猜它不喜欢输入上的 A(7)。
有任何想法吗?谢谢你。
为此,您只需像往常一样声明您的函数
function [a] = myFunction(b, c) a = b + c;
并提供A(7)作为输入:result=myFunction(b,A(7));.
A(7)
result=myFunction(b,A(7));