matlab constant anonymous function returns only one value instead of an array

前端 未结 2 719
臣服心动
臣服心动 2021-01-29 12:54

I\'ve been searching the net for a couple of mornings and found nothing, hope you can help.

I have an anonymous function like this

f = @(x,y) [sin(2*pi*x         


        
2条回答
  •  南方客
    南方客 (楼主)
    2021-01-29 13:13

    You are defining a function f = @(x,y) [0, 1]; which has the input parameters x,y and the output [0,1]. What else do you expect to happen?

    Update:

    This should match your description:

    g=@(x,y)[zeros(size(x)),ones(size(y))]
    g(x',y')
    

提交回复
热议问题