title: How to change variable value in a function of Matlab
body: <p>The code:</p>
  
  <pre><code>function send_Callback(hObject, eventdata, handles)
           key = 3; %this is the variable
           current = str2double(get(handles.value, 'String'));
           %value is a textbox where user put input
           newValue = key+current;
           set(handles.listbox1,'String', newValue)
           %listbox1 is a listbox to show the value
           %Now I want to replace the value of key by the value of current
           %key = current - something like this
  </code></pre>
  
  <p><strong>What I am expecting:</strong> I am expecting the key will be replaced with the current value (e.g. 8). So that when I will again input something in my textbox (e.g. 12), it will be added with previous current value (e.g. 8, and then newValue will be 12+8).</p>
  
  <p><strong>What I am getting:</strong> Whenever I am clicking the button the key is set to 3 every time and adding with current value. But I want the key to be changed permanently or atleast be put aside after first use.</p>
  
  <p><strong>Obligations:</strong> The key value which is shown as 3 here has to be exactly as 3 when I am starting my program and clicking the send button for the first time. Actually I will be using the above concept for encryption/decryption later on [for building block I am using just an addition], so for the first time my key has to be known to the device, then the user can change it when she wants.</p>
  
  <p><strong>Additional comment:</strong> <a href="https://stackoverflow.com/questions/20653430/how-to-replace-the-variable-value-permanently">My previous post</a> was almost similar but my requirement of updating the variable was still unfulfilled. The purpose was served though that time.</p>