You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: write_action.m
    path of file: ./repos/cocoSim-deprecated/src/middleEnd
    
    the code of the file until where you have to start completion: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This file is part of CoCoSim.
% Copyright (C) 2014-2016  Carnegie Mellon University
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function [action_code, external_nodes, variables_struct_output, node_struct] = write
    
function %s not in nodes struct',char(function_call))
        end
        
        
    else

        var_index = find(strcmp({variables_struct_output.Name},variable_to_be_updated));
        if ~isempty(var_index)
            s = rmfield(variables_struct_output(var_index),{'index','used'});
            node_struct.Parameters = [node_struct.Parameters, setdiff_struct( s, node_struct.Parameters)];
            node_struct.Outputs = [node_struct.Outputs, setdiff_struct( s, node_struct.Outputs)];
            index = variables_struct_output(var_index).index;
        else
             error('error : %s does not exist',char(variable_to_be_updated))
        end