function with two inputs, one queue, and one element in matlab

main.m
function [out_queue] = add_to_queue(in_queue, elem)
% This function adds an element to the end of the given queue
% Inputs:
%   in_queue: the input queue
%   elem: the element to be added to the queue
% Outputs:
%   out_queue: the updated queue with the new element

% Append the element to the end of the queue
out_queue = [in_queue, elem];
end
346 chars
12 lines

Here, we define a function add_to_queue that takes two input arguments: in_queue (the queue which we want to add an element to) and elem (the element that we want to add to the queue). The function then appends the elem to the end of the in_queue, and outputs the updated queue as out_queue.

gistlibby LogSnag