MATLAB Answers

0

GUI handles issue and behavior in 2019a but not in 2013b

Frank Lanni さんによって質問されました 2019 年 10 月 10 日
最新アクティビティ Frank Lanni さんによって コメントされました 2019 年 10 月 11 日
when this gets called in V 2013a the gui comes up with check boxes for scaling several parameters.
when this gets called in V 2019a the gui comes up with check boxes for only scaling a couple of parameters and leaves out the rest
the errors i get in the command window are:
Reference to non-existent field 'pitch'.
Error in GUI_scaling>GUI_scaling_OutputFcn (line 69)
handles.pitch = g1data.pitch;
Error in gui_mainfcn (line 264)
feval(gui_State.gui_OutputFcn, gui_hFigure, [], gui_Handles);
Error in GUI_scaling (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in GUI_blade_design>scaling_options_Callback (line 900)
GUI_scaling %open scaling gui
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in GUI_blade_design (line 114)
gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)GUI_blade_design('scaling_options_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
Code is listed below:
function varargout = GUI_scaling(varargin)
% GUI_SCALING MATLAB code for GUI_scaling.fig
% GUI_SCALING, by itself, creates a new GUI_SCALING or raises the existing
% singleton*.
%
% H = GUI_SCALING returns the handle to a new GUI_SCALING or the handle to
% the existing singleton*.
%
% GUI_SCALING('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUI_SCALING.M with the given input arguments.
%
% GUI_SCALING('Property','Value',...) creates a new GUI_SCALING or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before GUI_scaling_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to GUI_scaling_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 GUI_scaling
% Last Modified by GUIDE v2.5 08-Aug-2018 15:08:36
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @GUI_scaling_OpeningFcn, ...
'gui_OutputFcn', @GUI_scaling_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 GUI_scaling is made visible.
function GUI_scaling_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 GUI_scaling (see VARARGIN)
% Choose default command line output for GUI_scaling
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% --- Outputs from this function are returned to the command line.
function varargout = GUI_scaling_OutputFcn(hObject, eventdata, handles)
%gather data from main gui
h = findobj('Tag','gui1');
g1data = guidata(h);
handles.pitch = g1data.pitch;
handles.pitch_angle = g1data.pitch_angle;
handles.skew = g1data.skew;
handles.skew_angle = g1data.skew_angle;
handles.chord = g1data.chord;
handles.total_rake = g1data.total_rake;
handles.design_rake = g1data.design_rake;
handles.tmax = g1data.tmax;
handles.camber_max = g1data.camber_max;
handles.rle = g1data.rle;
handles.tte = g1data.tte;
handles.blade_diameter = g1data.blade_diameter;
handles.hub_radius = g1data.hub_radius;
varargout{1} = handles.output;
guidata(hObject, handles);
% --- Executes on button press in scale.
function scale_Callback(hObject, eventdata, handles)
multiplication_factor = str2double(get(handles.multiplication_factor,'String')); %gets multiplication factor from text box
if isnan(multiplication_factor) %checks if it is a numerical value
disp('Input numerical multiplication factor before scaling')
return
end
%multiply all checked off linear measurements by the multiplication factor
if get(handles.pitch_check,'Value')
handles.pitch = handles.pitch*multiplication_factor;
end
if get(handles.chord_check,'Value')
handles.chord = handles.chord*multiplication_factor;
end
if get(handles.skew_angle_check,'Value')
handles.skew_angle = handles.skew_angle*multiplication_factor;
end
if get(handles.rake_check,'Value') %resolve the dependency of total rake and design rake
if get(handles.design_rake_button,'Value')
handles.design_rake = handles.design_rake*multiplication_factor;
handles.total_rake = handles.design_rake + (handles.skew.*sind(handles.pitch_angle));
else
handles.total_rake = handles.total_rake*multiplication_factor;
end
end
if get(handles.tmax_check,'Value')
handles.tmax = handles.tmax*multiplication_factor;
end
if get(handles.camber_max_check,'Value')
handles.camber_max = handles.camber_max*multiplication_factor;
end
if get(handles.rle_check,'Value')
handles.rle = handles.rle*multiplication_factor;
end
if get(handles.tte_check,'Value')
handles.tte = handles.tte*multiplication_factor;
end
if get(handles.blade_diameter_check,'Value')
handles.blade_diameter = handles.blade_diameter*multiplication_factor;
end
if get(handles.hub_radius_check,'Value')
handles.hub_radius = handles.hub_radius*multiplication_factor;
end
guidata(hObject, handles); %update handles structure
% --- Executes on button press in translate.
function translate_Callback(hObject, eventdata, handles)
translation_factor = str2double(get(handles.translation_factor,'String')); %gets addition factor from text box
if isnan(translation_factor) %checks if it has been entered
disp('Input numerical translation factor before scaling')
return
end
%add translation factor to all linear measurements
if get(handles.pitch_check,'Value')
handles.pitch = handles.pitch+translation_factor;
end
if get(handles.chord_check,'Value')
handles.chord = handles.chord+translation_factor;
end
if get(handles.skew_angle_check,'Value')
handles.skew_angle = handles.skew_angle+multiplication_factor;
end
if get(handles.rake_check,'Value') %resolve the dependency of total rake and design rake
if get(handles.design_rake_button,'Value')
handles.design_rake = handles.design_rake+translation_factor;
handles.total_rake = handles.design_rake + (handles.skew.*sind(handles.pitch_angle));
else
handles.total_rake = handles.total_rake+translation_factor;
end
end
if get(handles.tmax_check,'Value')
handles.tmax = handles.tmax+translation_factor;
end
if get(handles.camber_max_check,'Value')
handles.camber_max = handles.camber_max+translation_factor;
end
if get(handles.rle_check,'Value')
handles.rle = handles.rle+translation_factor;
end
if get(handles.tte_check,'Value')
handles.tte = handles.tte+translation_factor;
end
if get(handles.blade_diameter_check,'Value')
handles.blade_diameter = handles.blade_diameter+translation_factor;
end
if get(handles.hub_radius_check,'Value')
handles.hub_radius = handles.hub_radius+translation_factor;
end
guidata(hObject, handles);
% --- Executes on button press in save_close.
function save_close_Callback(hObject, eventdata, handles)
uiresume %resumes main GUI which initiates closing procedure
%creation functions-----
% --- Executes during object creation, after setting all properties.
function multiplication_factor_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes during object creation, after setting all properties.
function translation_factor_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

  2 件のコメント

Walter Roberson
2019 年 10 月 10 日
The code appears to rely upon there being a separate figure with tag gui1 . We as outside observers have no reason to expect that to be the case.
Also, you used findobj() which does not locate objects in handles whose handle visibility is set to off or callback. It is possible that gui1 does not have handle visibility set 'on' . If that is the case you might need to use findall() instead of findobj()
Frank Lanni 2019 年 10 月 10 日
yes, there is a separate figure with tag gui1. That figure has a "button" that launches the gui which is not showing up correctly.

サインイン to comment.

製品


リリース

R2019a

1 件の回答

Steven Lord
回答者: Steven Lord
2019 年 10 月 10 日

How does that button launch the GUI that's not showing up correctly? Does it call the GUI's function file or does it simply use openfig or something similar? If it uses openfig, change it to call the GUI's function file instead.

  1 件のコメント

Frank Lanni 2019 年 10 月 11 日
the code that launches the second gui is below. It calls the GUI's function name. The strange part is that a portion of the GUI shows up, but only showing the checkboxes for g4data.skwe_angle, and g4data.hub_radius, but none of the others.
% --- Executes on button press in scaling_options.
function scaling_options_Callback(hObject, eventdata, handles)
GUI_scaling %open scaling gui
uiwait(GUI_scaling) %pause main gui
h = findobj('Tag','gui4'); %completes once main gui has been resumed by scaling gui
if ~isempty(h)
g4data = guidata(h); %gather data back from scailing gui
handles.pitch = g4data.pitch;
handles.skew_angle = g4data.skew_angle;
handles.chord = g4data.chord;
handles.total_rake = g4data.total_rake;
handles.design_rake = g4data.design_rake;
handles.tmax = g4data.tmax;
handles.camber_max = g4data.camber_max;
handles.rle = g4data.rle;
handles.tte = g4data.tte;
handles.blade_diameter = g4data.blade_diameter;
handles.hub_radius = g4data.hub_radius;
run table_update %update the table
guidata(hObject, handles); %update handles structure
close GUI_scaling %close scaling gui
end

サインイン to comment.



Translated by