title: Write matlab data from gui to excel file and read only file
body: <p>I have a Matlab GUI that I generate values in and send to the workspace with the assignin() command.</p>
  
  <p>I need to be able to send the data that I generate to a read only file in excel. I also want the user to be able to name the file. I haven't been able to do this with either the xlswrite command or the save command. </p>
  
  <p>Thank you for your time in advance here is the code that I have been trying to use. </p>
  
  <pre><code>function save_Callback(hObject, eventdata, handles)
  % hObject    handle to save (see GCBO)
  % eventdata  reserved - to be defined in a future version of MATLAB
  % handles    structure with handles and user data (see GUIDATA)
  state=get(hObject, 'Value');
  if state==1
  global stop_state;
  stop_state = 0;
  pause(1);
  prompt = 'What is the file name you want to save to';
  filename = input(prompt,'s');
  new_file = strcat(filename,'.xlsx');
  xlswrite(new_file,y(idx));
  end 
  </code></pre>
  
  <p>I have been getting the error that the variables don't exist that i am sending over even though i can see  their name in the workspace.</p>