job.answiz.com
  • 1
Votes
name
name Punditsdkoslkdosdkoskdo

In MATLAB what is multiple return values from a function?

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 only returns "ans =" and the initialized array. How can I have it also set values of my other variables? Here's my code:

function [ array, listp, freep ] = initialize( size )
    array = zeros(size, 3);
    listp = 0;
    freep = 1;
end

Matlab allows you to return multiple values as well as receive them inline.

When you call it, receive individual variables inline:

[array, listp, freep] = initialize(size)
  • 0
Reply Report