2014-01-18 2 views
1

그래서 두 번의 푸시 사이에 기다렸다가 버튼이 표시되지만 오류가 계속 표시됩니다. 푸시 버튼 함수의 끝에서 "Return"을 사용하려고했지만 GUI에서 더 이상 명령을 사용하지 않고 ok라고 생각합니다.나는 MATLAB에서 2- 푸시 버튼을 사용하려했지만 일단 푸시 버튼을 누르고 다른 푸시 버튼을 사용하려고하면 오류가 발생합니다.

표시되는 오류는 다음과 같습니다

Undefined function 'uiControls' for input 
arguments of type 'struct'. 

Error in 
@(hObject,eventdata)uiControls('unitgroup_SelectionChangeFcn',get(hObject,'SelectedObject'),eventdata,guidata(get(hObject,'SelectedObject'))) 


Error in hgfeval (line 63) 
    feval(fcn{1},varargin{:},fcn{2:end}); 

Error in 
uitools.uibuttongroup/childAddedCbk>manageButtons 
(line 79) 
hgfeval(cbk, source, evdata); 

Error while evaluating uicontrol Callback 

I는 참조 용으로 작성한 코드 :

 function varargout = uiControls(varargin) 
    % UICONTROLS MATLAB code for uiControls.fig 
    %  UICONTROLS, by itself, creates a new UICONTROLS or raises the existing 
    %  singleton*. 
    % 
    %  H = UICONTROLS returns the handle to a new UICONTROLS or the handle to 
    %  the existing singleton*. 
    % 
    %  UICONTROLS('CALLBACK',hObject,eventData,handles,...) calls the local 
    %  function named CALLBACK in UICONTROLS.M with the given input arguments. 
    % 
    %  UICONTROLS('Property','Value',...) creates a new UICONTROLS or raises 
    %  the existing singleton*. Starting from the left, property value pairs are 
    %  applied to the GUI before uiControls_OpeningFcn gets called. An 
    %  unrecognized property name or invalid value makes property application 
    %  stop. All inputs are passed to uiControls_OpeningFcn via varargin. 
    % 
    %  *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one 
    %  instance to run (singleton)". 
    % 
    % See also: GUIDE, GUIDATA, GUIHANDLES 

    % Edit the above text to modify the response to help uiControls 

    % Last Modified by GUIDE v2.5 18-Jan-2014 00:48:05 

    % Begin initialization code - DO NOT EDIT 
    gui_Singleton = 1; 
    gui_State = struct('gui_Name',  mfilename, ... 
         'gui_Singleton', gui_Singleton, ... 
         'gui_OpeningFcn', @uiControls_OpeningFcn, ... 
         'gui_OutputFcn', @uiControls_OutputFcn, ... 
         'gui_LayoutFcn', [] , ... 
         'gui_Callback', []); 
    if nargin && ischar(varargin{1}) 
     gui_State.gui_Callback = str2func(varargin{1}); 
    end 

    if nargout 
     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); 
    else 
     gui_mainfcn(gui_State, varargin{:}); 
    end 
    % End initialization code - DO NOT EDIT 

    % --- Executes just before uiControls is made visible. 
    function uiControls_OpeningFcn(hObject, eventdata, handles, varargin) 
    % This function has no output args, see OutputFcn. 
    % hObject handle to figure 
    % eventdata reserved - to be defined in a future version of MATLAB 
    % handles structure with handles and user data (see GUIDATA) 
    % varargin command line arguments to uiControls (see VARARGIN) 
    % Choose default command line output for uiControls 
    % This section is used for displaying the logo of the SMERC 
    handles.output = hObject; 
    imshow('D:\SMERC\Abstract Model\Phani\Essentials\S1_new.jpg'); 
    g = warndlg('SMERC Randomizer User Guide> Select the desired number of ESM >> Press the Randomize Push button', 'Alert'); 
    waitfor(g); 
    % Update handles structure 
    guidata(hObject, handles); 
    initialize_gui(hObject, handles, false); 

    % --- Executes during object creation, after setting all properties. 
    function density_CreateFcn(hObject, eventdata, handles) 
    % hObject handle to density (see GCBO) 
    % eventdata reserved - to be defined in a future version of MATLAB 
    % handles empty - handles not created until after all CreateFcns called 
    % Hint: popupmenu controls usually have a white background on Windows. 
    %  See ISPC and COMPUTER. 
    if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 
     set(hObject,'BackgroundColor','white'); 
    end 

    %Randomizer Code~ Integrted into the Time Reference 
    % --- Executes when selected object is changed in uipanel13. 
    function uipanel13_SelectionChangeFcn(hObject, eventdata, handles) 
    % hObject handle to the selected object in uipanel13 
    % eventdata structure with the following fields (see UIBUTTONGROUP) 
    % EventName: string 'SelectionChanged' (read only) 
    % OldValue: handle of the previously selected object or empty if none was selected 
    % NewValue: handle of the currently selected object 
    % handles structure with handles and user data (see GUIDATA) 
    global tmp; 
    if hObject == handles.one 
    tmp=1; 
    elseif hObject == handles.two 
    tmp=2; 
    elseif hObject == handles.three 
    tmp=3; 
    elseif hObject == handles.four 
    tmp=4; 
    end 

    %Density=Valued Dec 
    function density_Callback(hObject, eventdata, handles) 
    % hObject handle to density (see GCBO) 
    % eventdata reserved - to be defined in a future version of MATLAB 
    % handles structure with handles and user data (see GUIDATA) 

    % Hints: get(hObject,'String') returns contents of density as text 
    %  str2double(get(hObject,'String')) returns contents of density as a double 
    density = str2double(get(hObject, 'String')); 
    if isnan(density) 
     set(hObject, 'String', 0); 
     errordlg('Input must be a number','Error'); 
    end 
    % Save the new density value 
    handles.metricdata.density = density; 
    guidata(hObject,handles) 

    % --- Executes during object creation, after setting all properties. 
    function volume_CreateFcn(hObject, eventdata, handles) 
    % hObject handle to volume (see GCBO) 
    % eventdata reserved - to be defined in a future version of MATLAB 
    % handles empty - handles not created until after all CreateFcns called 

    % Hint: popupmenu controls usually have a white background on Windows. 
    %  See ISPC and COMPUTER. 
    if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 
     set(hObject,'BackgroundColor','white'); 
    end 


    % %->Volume 
    % The value in the density block is set to 0 and get the value in the 
    % string So basically this is how we get the value in the GUI 
    function volume_Callback(hObject, eventdata, handles) 
    % hObject handle to volume (see GCBO) 
    % eventdata reserved - to be defined in a future version of MATLAB 
    % handles structure with handles and user data (see GUIDATA) 
    % Hints: get(hObject,'String') returns contents of volume as text 
    %  str2double(get(hObject,'String')) returns contents of volume as a double 
    volume = str2double(get(hObject, 'String')); 
    if isnan(volume) 
     set(hObject, 'String', 0); 
     errordlg('Input must be a number','Error'); 
    end 
    % Save the new volume value 
    handles.metricdata.volume = volume; 
    guidata(hObject,handles) 



    % --- Executes on button press in reset. 
    function reset_Callback(hObject, eventdata, handles) 
    % hObject handle to reset (see GCBO) 
    % eventdata reserved - to be defined in a future version of MATLAB 
    % handles structure with handles and user data (see GUIDATA) 
    initialize_gui(gcbf, handles, true); 

    % --- Executes when selected object changed in unitgroup. 
    function unitgroup_SelectionChangeFcn(hObject, eventdata, handles) 
    % hObject handle to the selected object in unitgroup 
    % eventdata reserved - to be defined in a future version of MATLAB 
    % handles structure with handles and user data (see GUIDATA) 
    set(handles.text4, 'String', 'Amps'); 
    set(handles.text5, 'String', '%'); 
    set(handles.text6, 'String', 'Amps'); 
    global x; 
    if hObject == handles.english 
    x=1 
    elseif hObject == handles.afterNoon 
    x=2 
    elseif hObject == handles.night 
    x=3 
    end 

    % --- Executes on button press in pushbutton9. 
    function pushbutton9_Callback(hObject, eventdata, handles) 
    % hObject handle to pushbutton9 (see GCBO) 
    % eventdata reserved - to be defined in a future version of MATLAB 
    % handles structure with handles and user data (see GUIDATA) 
    format long; 
    global tmp; 
    %disp(tmp); 
    disp('SMERC-Phani Madhav Yannam'); 
    cd('D:\SMERC\Abstract Model\new\Model+XML\xmlout'); 
    %warning('Enter a value greater than Zero'); 

    for i=1:tmp; 
        [files{i}] = uigetfile('.xml'); 
        % delete XY after you validate the Time Stamp and the ESM 
        % IDs 
        %xy{i}=files{i}; 
    end 
    new_counttv(tmp)=0; 
    new_countFan(tmp)=0; 
    new_countFL(tmp)=0; 
    new_countIL(tmp)=0; 
    new_countDW(tmp)=0; 
    new_countWS(tmp)=0; 
    new_countAC(tmp)=0; 
    new_countVC(tmp)=0; 
    new_countMW(tmp)=0; 
    global result1; 
    global amp; 
    result1=[]; 
     amp=0; 
     %sum_load=0; 
     for i = 1:tmp; 
        docNode = xmlread(files{i}); 
        root = docNode.getDocumentElement; 
        tag = root.getElementsByTagName('total_amperage'); 
        loads1 = []; 
        for k = 0:tag.getLength-1 
         node = tag.item(k); 
        loads1 = cat(2,loads1,[node.getTextContent]); 
        end 
        fprintf('The total amperage of the Apartment %d:%d \n',i); 
        disp(loads1); 
        amp=amp+str2double(loads1); 
        result1 = cat(2,result1,loads1); 
        %loads(i) = str2double(char(tag.getTextContent)); 
     end 

        fprintf('The Total Amperage of %d Apartments: %d \n',tmp,int16(amp)); 
        global newloads; 
        global loads; 
        global y; 
        result=[]; 
        new_result=[]; 
        for i = 1:tmp; 
        fprintf('Report for the Apartment %d: \n',i); 
        fprintf('The devices list in the Apartment %d: \n',i); 
        docNode = xmlread(files{i}); 
        root = docNode.getDocumentElement; 
        tag = root.getElementsByTagName('device'); 
        loads = []; 
        newloads=[]; 
        for k = 0:tag.getLength-1 
         node = tag.item(k); 
         disp([node.getTextContent]); 
         loads = cat(2,loads,[node.getTextContent]); 
         ll=length(loads); 
        end 
    %  for j=1:ll    
    %  if loads(j)=='TV'; 
    %   new_counttv(i)= new_counttv(i)+1 
    %  elseif loads(j)=='Fan'; 
    %   new_countFan(i)= new_countFan(i)+1 
    %  elseif loads(j)== 'Fluorescent Light'; 
    %   new_countFL(i)= new_countFL(i)+1 
    %  elseif loads(j)== 'Incandescent Light'; 
    %   new_countIL(i)= new_countIL(i)+1 
    %  elseif loads(j)== 'AC'; 
    %   new_countAC(i)= new_countAC(i)+1 
    %  elseif loads(j)== 'Dishwasher'; 
    %   new_countDW(i)= new_countDW(i)+1 
    %  elseif loads(j)== 'Washer'; 
    %   new_countWS(i)= new_countWS(i)+1 
    %  elseif loads(j)== 'Vaccumm'; 
    %   new_countVC(i)= new_countVC(i)+1 
    %  elseif loads(j)=='Microwave'; 
    %   new_countMW(i)=new_count(i)+1; 
    %  end 
    %  end 
        for j=1:ll 
        if strcmp(loads(j),'TV'); 
         new_counttv(1,i)= new_counttv(i)+1; 
        elseif strcmp(loads(j),'Fan'); 
         new_countFan(1,i)= new_countFan(i)+1; 
         disp(new_countFan(1,i)); 
        elseif strcmp(loads(j),'Fluorescent Light'); 
         new_countFL(1,i)= new_countFL(i)+1; 
        elseif strcmp(loads(j),'Incandescent Light'); 
         new_countIL(1,i)= new_countIL(i)+1; 
        elseif strcmp(loads(j),'AC'); 
         new_countAC(1,i)= new_countAC(i)+1; 
        elseif strcmp(loads(j),'Dishwasher'); 
         new_countDW(1,i)= new_countDW(i)+1; 
        elseif strcmp(loads(j),'Washer'); 
         new_countWS(1,i)= new_countWS(i)+1; 
        elseif strcmp(loads(j),'Vaccuum Cleaner'); 
         new_countVC(1,i)= new_countVC(i)+1; 
        elseif strcmp(loads(j),'Microwave'); 
         new_countMW(1,i)=new_count(i)+1; 
        end 
        end 

        result= cat(2,result,loads); 
        new_result=cat(2,new_result,loads); 
        y=length(result); 
        size(i+1)= length(result); 
        end 

    %    ----------------------------------------------- 
    %    new_loads=[]; 
    %    for i = 1:tmp; 
    %     docNode = xmlread(files{i}); 
    %     root = docNode.getDocumentElement; 
    %     tag = root.getElementsByTagName('device'); 
    %     for k = 0:tag.getLength-1 
    %      node = tag.item(k); 
    %      %disp([node.getTextContent]); 
    %      
    %      str=str2num([node.getTextContent])     
    %      %combinedStr = strcat(str, str) 
    %      %str= strcat(str,' morning') 
    %      new_loads = cat(2,loads,[node.getTextContent]);     
    %     end 
    %    end 
    % %    
    %    ----------------------------------------------- 

    %Functions for Searches through the documents- 
    % for i=1:tmp 
    % for k=1:y 
    %  if new_result(k)== 'TV'; 
    %   new_counttv(i)= new_counttv(i)+1 
    %  elseif new_result(k)== 'Fan'; 
    %   new_countFan(i)= new_countFan(i)+1 
    %  elseif new_result(k)== 'Fluorescent Light'; 
    %   new_countFL(i)= new_countFL(i)+1 
    %  elseif new_result(k)== 'Incandescent Light'; 
    %   new_countIL(i)= new_countIL(i)+1 
    %  elseif new_result(k)== 'AC'; 
    %   new_countAC(i)= new_countAC(i)+1 
    %  elseif new_result(k)== 'Dishwasher'; 
    %   new_countDW(i)= new_countDW(i)+1 
    %  elseif new_result(k)== 'Washer'; 
    %   new_countWS(i)= new_countWS(i)+1 
    %  elseif new_result(k)== 'Vaccumm'; 
    %   new_countVC(i)= new_countVC(i)+1 
    %  elseif new_result(k)=='Microwave'; 
    %   new_countMW(i)=new_count(i)+1; 
    %  end 
    % end  
    % end 
    % 
    %    for i=tmp:-1:1 
    %     if i>1 
    %      new_counttv(i)=new_counttv(i)-new_counttv(i-1); 
    %      fprintf('The total number of TV in the Aparment %d are: %d \n',i,new_counttv(i)); 
    %      fprintf('The total number of devices in the Apartment %d are: %d \n',i,n(i)); 
    %     else 
    %      fprintf('The total number of TV in the Aparment %d are: %d \n',i,new_counttv(i)); 
    %     end 
    %    end 


        for i=tmp:-1:1 
         n(i)=size(i+1)-size(i); 
         fprintf('The total number of devices in the Apartment %d are: %d \n',i,n(i)); 

         %loads(i) = str2double(char(tag.getTextContent)); 
        end 
       %_----------------------------------------------- 
    for i=1:tmp 
       fprintf('Apt %d TV: %d \n ',i,(new_counttv(i))); 
       fprintf('Apt %d Fan: %d \n ',i,(new_countFan(i))); 
       fprintf('Apt %d FL: %d \n ',i,(new_countFL(i))); 
       fprintf('Apt %d IL: %d \n ',i,(new_countIL(i))); 
       fprintf('Apt %d AC: %d \n ',i,(new_countAC(i))); 
       fprintf('Apt %d VC: %d \n ',i,(new_countVC(i))); 
       fprintf('Apt %d DW: %d \n ',i,(new_countDW(i))); 
       fprintf('Apt %d WS: %d \n ',i,(new_countWS(i))); 
       fprintf('Apt %d MW: %d \n ',i,(new_countMW(i))); 
    end 
        n_boundrand_tv(tmp)=0; 
        n_boundrand_fn(tmp)=0; 
        n_boundrand_IL(tmp)=0; 
        n_boundrand_AC(tmp)=0; 
        n_boundrand_DW(tmp)=0; 
        n_boundrand_WS(tmp)=0; 
        n_boundrand_FL(tmp)=0; 
        n_boundrand_VC(tmp)=0; 
        n_boundrand_MW(tmp)=0; 
        n_rand_total(tmp)=0; 

        for i=1:tmp 
      if new_counttv(i)<1; 
      n_boundrand_tv(i)=0; 
      else 
      n_boundrand_tv(i) =n_boundrand_tv(i)+randi([0,new_counttv(i)]); 
      n_rand_total(i)= n_boundrand_tv(i)+n_rand_total(i); 
      end 

      if new_countFan(i)<1; 
      n_boundrand_fn(i)=0; 
      else 
      n_boundrand_fn(i)=n_boundrand_fn(i)+randi([0,new_countFan(i)]); 
      n_rand_total(i)=n_rand_total(i)+n_boundrand_fn(i); 
      end 

      if new_countIL(i)<1; 
      n_boundrand_IL(i)=0; 
      else 
      n_boundrand_IL(i)=n_boundrand_IL(i)+randi([0,new_countIL(i)]); 
      n_rand_total(i)=n_rand_total(i)+n_boundrand_IL(i); 
      end 

      if new_countFL(i)<1; 
      n_boundrand_FL(i)=0; 
      else 
      n_boundrand_FL(i)=n_boundrand_FL(i)+randi([0,new_countFL(i)]); 
      n_rand_total(i)=n_rand_total(i)+n_boundrand_FL(i); 
      end 

      if new_countAC(i)<1; 
      n_boundrand_AC(i)=0; 
      else 
      n_boundrand_AC(i)=n_boundrand_AC(i)+randi([0,new_countAC(i)]); 
      n_rand_total(i)=n_rand_total(i)+n_boundrand_AC(i); 
      end 

      if new_countDW(i)<1; 
      n_boundrand_DW(i)=0; 
      else 
      n_boundrand_DW(i)=n_boundrand_DW(i)+randi([0,new_countDW(i)]); 
      n_rand_total(i)=n_rand_total(i)+n_boundrand_DW(i); 
      end 

      if new_countWS(i)<1; 
      n_boundrand_WS(i)=0; 
      else 
      n_boundrand_WS(i)=n_boundrand_WS(i)+randi([0,new_countWS(i)]); 
      n_rand_total(i)=n_rand_total(i)+n_boundrand_WS(i); 
      end 

      if new_countVC(i)<1; 
      n_boundrand_VC(i)=0; 
      else 
      n_boundrand_VC(i)=n_boundrand_VC(i)+randi([0,new_countVC(i)]); 
      n_rand_total(i)=n_rand_total(i)+n_boundrand_VC(i); 
      end 

      if new_countMW(i)<1; 
      n_boundrand_MW(i)=0; 
      else 
      n_boundrand_MW(i)=n_boundrand_MW(i)+randi([0,new_countMW(i)]); 
      n_rand_total(i)=n_rand_total(i)+n_boundrand_MW(i); 
      end 
        end 

      global n_a; 
      n_a=sum(n_rand_total); 
      fprintf('After Randomising the %d Apartments, The list of %d random devices are:\n \n',tmp,n_a); 


    %----------------------------------------------------------------------------- 
       % Delete the below values // n-disp the below 
       global rcounttv; 
       global rcountFan; 
       global rcountFL; 
       global rcountIL; 
       global rcountAC; 
       global rcountDW; 
       global rcountWS; 
       global rcountVC; 
       global rcountMW; 

       global counttv; 
       global countFan; 
       global countFL; 
       global countIL; 
       global countDW; 
       global countWS; 
       global countAC; 
       global countVC; 
       global countMW; 

       counttv=0; 
       countFan=0; 
       countFL=0; 
       countIL=0 ; 
       countDW=0; 
       countWS=0; 
       countAC=0; 
       countVC=0; 
       countMW=0; 



    disp('Report:'); 
       fprintf('Total Number of TV in the %d Apartments are: %d \n',tmp,sum(new_counttv)); 
       fprintf('Total Number of Fan in the %d Apartments are: %d \n',tmp,sum(new_countFan)); 
       fprintf('Total Number of Flourescent lights in the %d Apartments are: %d \n',tmp,sum(new_countFL)); 
       fprintf('Total Number of Incadescent Light in the %d Apartments are: %d \n',tmp,sum(new_countIL)); 
       fprintf('Total Number of Dishwashers in the %d Apartments are: %d \n',tmp,sum(new_countDW)); 
       fprintf('Total Number of AC in the %d Apartments are: %d \n',tmp,sum(new_countAC)); 
       fprintf('Total Number of Vacuum Cleaners in the %d Apartments are: %d \n',tmp,sum(new_countVC)); 
       fprintf('Total Number of Microwave in the %d Apartments are: %d \n',tmp,sum(new_countMW)); 
       fprintf('Total Number of Washers in the %d Apartments are : %d \n \n',tmp, sum(new_countWS)); 


      fprintf('After Randomising the %d Apartments, The list of %d random devices are:\n \n',tmp,sum(n_a)); 
      % Print the list of the random devices. 

      for j=1:tmp 
       if n_boundrand_AC(j)>0 
        for i=1:n_boundrand_AC(j) 
         disp('AC'); 
        end 
       end 

       if n_boundrand_tv(j)>0 
       for i=1:n_boundrand_tv(j) 
        disp('TV'); 
       end 
       end 

       if n_boundrand_fn(j)>0 
       for i=1:n_boundrand_fn(j) 
        disp('Fan'); 
       end 
       end 

       if n_boundrand_FL(j)>0 
       for i=1:n_boundrand_FL(j) 
        disp('Flourescent Light'); 
       end 
       end 

       if n_boundrand_IL(j)>0 
       for i=1:n_boundrand_IL(j) 
        disp('Incadescent Light'); 
       end 
       end 

       if n_boundrand_DW(j)>0 
       for i=1:n_boundrand_DW(j) 
        disp('Dishwashers'); 
       end 
       end 

       if n_boundrand_VC(j)>0 
       for i=1:n_boundrand_VC(j) 
        disp('Vacumm Cleaner'); 
       end 
       end 

       if n_boundrand_MW(j)>0 
       for i=1:n_boundrand_MW(j) 
        disp('Microwave'); 
       end 
       end 

       if n_boundrand_WS(j)>0 
       for i=1:n_boundrand_WS(j) 
        disp('Washers'); 
       end 
       end 
      end 
      fprintf('\n'); 

      AC=18; 
      MW=10; 
      WS=5; 
      DW=18; 
      FL=0.2; 
      IL=0.5; 
      tv=1.5; 
      fan=1.5; 
      VC= 7.3; 

      global rts;  
      rts=(sum(n_boundrand_tv*tv))+(sum(n_boundrand_fn)*fan)+(sum(n_boundrand_FL)*FL)+(sum(n_boundrand_IL)*IL)+(sum(n_boundrand_DW)*DW)+(sum(n_boundrand_WS)*WS)+(sum(n_boundrand_AC*AC))+(sum(n_boundrand_VC)*VC)+(sum(n_boundrand_MW)*MW); 

      fprintf('Random Engine Report: \n');        
      fprintf('Total Number of TV in the %d Apartments are: %d \n',tmp,sum(n_boundrand_tv)); 
      fprintf('Total Number of Fan in the %d Apartments are: %d \n',tmp,sum(n_boundrand_fn)); 
      fprintf('Total Number of Flourescent lights in the %d Apartments are: %d \n',tmp,sum(n_boundrand_FL)); 
      fprintf('Total Number of Incadescent Light in the %d Apartments are: %d \n',tmp,sum(n_boundrand_IL)); 
      fprintf('Total Number of Dishwashers in the %d Apartments are: %d \n',tmp,sum(n_boundrand_DW)); 
      fprintf('Total Number of AC in the %d Apartments are: %d \n',tmp,sum(n_boundrand_AC)); 
      fprintf('Total Number of Vacuum Cleaners in the %d Apartments are: %d \n',tmp,sum(n_boundrand_VC)); 
      fprintf('Total Number of Microwave in the %d Apartments are: %d \n',tmp,sum(n_boundrand_MW)); 
      fprintf('Total Number of Washers in the %d Apartments are: %d \n', tmp, sum(n_boundrand_WS)); 

    % should be random sum // is it ? 
    % Demand Response 
    %rts=int16(((rcounttv*tv)+(rcountFan*fan)+(rcountFL*FL)+(rcountIL*IL)+(rcountDW*DW)+(rcountWS*DW)+(rcountAC*AC)+(rcountMW*MW)+(rcountVC*VC))); 
    fprintf('The total amperage of the generated devices by the engine is %d \n', int16(rts)); 
    return; 



    % -------------------------------------------------------------------- 


    % --- Executes on button press in calculate. 
    function calculate_Callback(hObject, eventdata, handles) 
    % hObject handle to calculate (see GCBO) 
    % eventdata reserved - to be defined in a future version of MATLAB 
    % handles structure with handles and user data (see GUIDATA) 

    mass = handles.metricdata.density * handles.metricdata.volume; 
    set(handles.mass, 'String', mass); 

    function initialize_gui(fig_handle, handles, isreset) 
    % If the metricdata field is present and the reset flag is false, it means 
    % we are we are just re-initializing a GUI by calling it from the cmd line 
    % while it is up. So, bail out as we dont want to reset the data. 
    if isfield(handles, 'metricdata') && ~isreset 
     return; 
    end 

    handles.metricdata.density = 0; 
    handles.metricdata.volume = 0; 

    set(handles.density, 'String', handles.metricdata.density); 
    set(handles.volume, 'String', handles.metricdata.volume); 
    set(handles.mass, 'String', 0); 

    set(handles.unitgroup, 'SelectedObject', handles.english); 

    set(handles.text4, 'String', 'Amps'); 
    set(handles.text5, 'String', '%'); 
    set(handles.text6, 'String', 'Amps'); 

    % Update handles structure 
    guidata(handles.figure1, handles); 
+0

이 오류를 생성하는 코드를 표시해주세요. – darthbith

+0

@darthbith : 게시물에 코드를 추가했습니다. 이 코드는 기본적으로 누름 단추를 누를 때 XML을 구문 분석하고 다른 두 누름 단추를 누를 때 다시 계산하는 데 사용됩니다. 누름 단추를 누를 때 프로그램이 잘 진행되지만 다른 누름 단추를 사용할 수 없습니다. 구조체 오류가 표시됩니다. – MAV

답변

1

위의 문제에 대한 답은 변경 디렉터리입니다. 그것은 실제로 명령 행의 전체 디렉토리를 변경합니다. GUI가 GUI 자체를 다시 초기화하지는 않습니다. 오히려 정확한 구문을 사용하는 것이 아마도 우리를 도울 것입니다.

이 문제를 해결하기 위해 다음 코드를 사용해 보았습니다.

[files{i}] = uigetfile('*.xml','Hello','D:\SMERC\Abstract Model\new\Model+XML\xmlout') 
관련 문제