MATLAB - multiple return values from a function?

前端 未结 4 409
隐瞒了意图╮
隐瞒了意图╮ 2021-02-04 23:35

I\'m writing 2 functions in matlab, an initialize function and a function to insert items into an array treating it like a doubly-linked list. However, my initialize function on

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-05 00:01

    Use the following in the function you will call and it will work just fine.

         [a b c] = yourfunction(optional)
         %your code
         a = 5;
         b = 7;
         c = 10;
         return
         end
    

    This is a way to call the function both from another function and from the command terminal

         [aa bb cc] = yourfunction(optional);
    

    The variables aa, bb and cc now hold the return variables.

提交回复
热议问题