Call function for all elements in an array

后端 未结 4 1050
鱼传尺愫
鱼传尺愫 2021-01-03 08:20

Let\'s say I have a function, like:

function [result] = Square( x )
    result = x * x;
end

And I have an array like the following,

4条回答
  •  忘掉有多难
    2021-01-03 09:03

    Have you considered the element-by-element operator .*?

    See the documentation for arithmetic operators.

提交回复
热议问题