Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab 桂元';除非单选按钮循环使用,否则不能正常运行_Matlab_User Interface - Fatal编程技术网

Matlab 桂元';除非单选按钮循环使用,否则不能正常运行

Matlab 桂元';除非单选按钮循环使用,否则不能正常运行,matlab,user-interface,Matlab,User Interface,我已经创建了一个GUI,它根据ui面板中提供的一些标准(以单选按钮作为选项),估计建造房屋所涉及的材料和价格。问题是,除非先播放单选按钮,否则点击GUI的go按钮会抛出错误。当GUI运行时,我不能将按钮保留在所选位置。如何运行.m文件,然后点击.fig上的go,而不必触摸任何东西(除了填写平方英尺编辑框) 以上是四个带有单选按钮的UI面板之一,仅举一个例子。它们的书写方式大致相同。下面是go按钮回调的片段 function GoBut_Callback(hObject, eventdata, h

我已经创建了一个GUI,它根据ui面板中提供的一些标准(以单选按钮作为选项),估计建造房屋所涉及的材料和价格。问题是,除非先播放单选按钮,否则点击GUI的go按钮会抛出错误。当GUI运行时,我不能将按钮保留在所选位置。如何运行.m文件,然后点击.fig上的go,而不必触摸任何东西(除了填写平方英尺编辑框)

以上是四个带有单选按钮的UI面板之一,仅举一个例子。它们的书写方式大致相同。下面是go按钮回调的片段

function GoBut_Callback(hObject, eventdata, handles)
% hObject    handle to GoBut (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
run('UrlPrice.m');
BathRoom = getappdata(handles.uibuttongroup3,'BathRoom');
BathSq = getappdata(handles.uibuttongroup3,'BathSq');
BathWall = getappdata(handles.uibuttongroup3,'BathWall');
% Floor = get(handles.Floor,'value')
HomeName = get(handles.HomeName,'string');

Base = get(handles.BaseSqFt, 'string');
BaseSqFt = str2num(Base);

TotSqFt = BaseSqFt .* Floor; 

Perim = (((BaseSqFt .^ .5) .* 4) .* Floor);
Perim2 = (BaseSqFt .^ .5) .*4;
Perim3 = (BaseSqFt .^ .5);

WallLnFt_01 = Perim + (BedWall .* 2) + (BathWall .* 2); % double side wall
WallLnFt_02 = Perim + BedWall + BathWall; % one side wall

IntDoor = (BedRoom .* 2) + (BathRoom) + 2; 
Tile = ceil(BathSq/17.44287); 
Thinset = BathRoom + 1; 

Index of element to remove exceeds matrix dimensions.
错误消息:

Index of element to remove exceeds matrix dimensions.

Error in cur2str (line 75)
t(1,:) = [];

Error in HomeBuilding>GoBut_Callback (line 267)
EstMat = cur2str(EstMat1,2);

Error in gui_mainfcn (line 95)
    feval(varargin{:});

Error in HomeBuilding (line 42)
gui_mainfcn(gui_State, varargin{:});

Error in       @(hObject,eventdata)HomeBuilding('GoBut_Callback',hObject,eventdata,guidata(hObject))


Error while evaluating UIControl Callback

您可以使用
setappdata
存储变量,以便以后在
ui按钮组3\u selection changedfcn
中使用。问题是,这只能在该函数中完成。这意味着在调用
uibuttongroup3\u SelectionChangedFcn
之前,变量不会被存储,这只有在按您所说的单选按钮播放时才会发生。

当GUI打开时,变量尚未定义。因此,您应该使用一些默认值在
OpeningFcn
中定义三个变量,或者确保用户在点击go之前设置了按钮。

您得到的错误是什么?变量
BathWall
BathSq
bathway
是否已初始化(例如,在guy
OpeningFunction
?我没有使用
OpeningFcn
做过任何事情。上面列出的就是我所做的一切。我是matlab新手,希望学习。我将编辑带有错误消息的原始问题。现在,GUI选择默认为每个面板的第一个选项。是吗有一种方法我可以删除选择,这样用户在开始时就必须选择一个(而不是必须在按钮之间循环),正如我所说,您应该将默认值添加到
OpeningFcn
,这样就不会产生错误。如果您希望强制用户选择,请将默认值设置为无效值(例如负数)并在按钮回调中检查参数的有效性。
Index of element to remove exceeds matrix dimensions.

Error in cur2str (line 75)
t(1,:) = [];

Error in HomeBuilding>GoBut_Callback (line 267)
EstMat = cur2str(EstMat1,2);

Error in gui_mainfcn (line 95)
    feval(varargin{:});

Error in HomeBuilding (line 42)
gui_mainfcn(gui_State, varargin{:});

Error in       @(hObject,eventdata)HomeBuilding('GoBut_Callback',hObject,eventdata,guidata(hObject))


Error while evaluating UIControl Callback