title: How to change values in an array (MATLAB GUIDE GUI)
body: <p>I was wondering what a function would look like in order to change values in an array according to its location. In the script I have attached, I use a function I wrote to generate an array for voltage and current and plot these values in order to give me my IV curve. The inputdlg feature however is not in use. I would like to use the inputdlg box to re run the function for calculating I and V, then I would replace values in the first array with these new values and plot the changes. What I want to know is how to perform some function upon clicking OK on the dialog box and replacing values in an existing array with the output values from the function at a location specified by the user.</p>
  
  <p>Here is where I start: all of these inputs are from edit boxes in the GUI</p>
  
  <pre><code>function plot_button_Callback(hObject, eventdata, handles)
  % hObject    handle to plot_button
  % Get user input from GUI
  NumS = str2double(get(handles.NumSeries_input,'String'));
  %number of cells in series
  NumP = str2double(get(handles.NumParallel_input,'String'));
  %number of cells in parallel
  Rs = eval(get(handles.Rseries_input,'String'));%Series resistance (Ohm)
  Rsh = eval(get(handles.Rshunt_input,'String')); %Shunt resistance (Ohm)
  Isc = eval(get(handles.Isc_input,'String')); %Short circuit current (A)
  Voc = eval(get(handles.Voc_input,'String')); %Open circuit voltage (V)
  n = eval(get(handles.n_input,'String')); %Ideality factor 
  % Calculate data
  </code></pre>
  
  <p>Here I open up a dialog box in order to set the params for the new cell</p>
  
  <pre><code>headers ={'Param1' 'Param2' 'Param3' 'Param4' 'Param5' 'Location'};
  dlg_title = 'Input';
  num_lines = 1;
  def = round(rand(1,6)*20);
  def = def';
  def = num2str(def);
  deff = cellstr(def);
  answer = inputdlg(headers, dlg_title, num_lines, deff);
  %Constants
  %Parameters
  </code></pre>
  
  <p>CalculationIVRsRsh is defined else where in my code</p>
  
  <pre><code>T=-140; %Temperature in degree C
  
  %Constantes
  q=1.602176565e-19; %Charge elementaire (C)
  k=1.3806488e-23; %Boltzmann constant (J/K)
  
  %Size of the cell
  [garb, taille]=size(Isc);
  %Calculation of each cell characteristics
  for ind=1:taille
  [I(:,ind), V(:,ind)]=CalculationIVRsRsh(Isc(ind),Voc(ind),T,n(ind),Rs(ind),Rsh(ind));
  end
  </code></pre>
  
  <p>Here I replicate the Current (I) array according to how many cells are in parallel</p>
  
  <pre><code>%Combination of the 3 solar cells
  Isc3=min(Isc);
  IscTm=repmat(Isc',1,NumP); %replicates the input vector for the Isc
  %according to how many of the cells in the array are in parallel
  IscT=sum(IscTm,2); %sums the Isc for the array
  Isc4=min(IscT);  %takes the current limitting value
  Iint=-Isc3/20:0.01:min(Isc3);
  IintP1=repmat(Iint,NumP,1); %replicates the values for Iint for the IV curve
  IintP=sum(IintP1,1); %adds the IintP1 values to simulate the adding currents
  
  for ind=1:taille
  Vint(:,ind)=interp1(I(:,ind),V(:,ind),Iint);
  IscN(ind)=interp1(V(:,ind),I(:,ind),0);
  end
  %We are doing the sum of V starting from the lowest I, therefore the 2
  %other cells are already at a positive voltage for which the sum is the
  %minimum value we can obtain for the 3 junction cell
  </code></pre>
  
  <p>Here I replicate the voltage array according to how many cells are in series</p>
  
  <pre><code>Isc3=min(IscN);
  V3=sum(Vint,2);
  Vs=repmat(V3,1,NumS);
  V4=sum(Vs,2);
  
  Voc3=sum(Voc);
  VocT=NumS.*Voc3;
  </code></pre>
  
  <p>Then I plot new data</p>
  
  <pre><code>%plots data
  V3=cat(1,V3,0);
  I3=cat(1,Iint',Isc3);
  I4=cat(1,IintP',Isc4);
  V4=cat(1,V4,0);
  plot(V3,I3,V4,I4)
  axis([0 VocT+VocT/20 0 max(IscT)+max(IscT)/20]);
  xlabel('V (V)');
  ylabel('I (A)');
  legend('Cell', 'Array');
  </code></pre>