No result being displayed in Edit box
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Avinav Kumar
am 16 Mär. 2021
Beantwortet: Aghamarsh Varanasi
am 18 Mär. 2021
Using some value in listbox1 i am calculating value d which is being entered into edit9. The value in edit9 and some other value in edit10 (calculated in same way as edit9) , needs to be added and fed to edit21. But i am getting no value in edit21. Please guide
function listbox1_Callback(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns listbox1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox1
b = str2double(handles.edit1.String);
% Get list of everything in the listbox.
listboxItems = handles.listbox1.String;
% Get the index of the item they selected.
selectedItem = handles.listbox1.Value;
% Turn that selection into a double number.
listboxNumber = str2double(listboxItems{selectedItem});
listboxString = listboxItems{selectedItem};
c = -inf;
if strcmpi (listboxString,'None')
handles.listbox2.Enable ='Off';
handles.listbox3.Enable ='Off';
handles.listbox4.Enable ='Off';
handles.listbox5.Enable ='Off';
handles.listbox6.Enable ='Off';
warningMessage = sprintf('No Rod has been Selected');
uiwait(errordlg(warningMessage));
handles.edit9.String = 'No Rod has been Selected';
set(handles.edit1,'String','');
set(handles.edit9,'String','');
handles.edit1.Enable ='Off';
handles.edit9.Enable = 'Off';
elseif listboxNumber == 1.25
handles.listbox2.Enable ='On';
handles.edit1.Enable = 'On';
handles.edit9.Enable = 'On';
c = 4.538;
if isnan(b)
warningMessage = sprintf('Length of Rod Taper is empty');
uiwait(errordlg(warningMessage));
handles.edit9.String = 'Length of Rod Taper is empty'
return;
end
elseif listboxNumber == 1.125
handles.listbox2.Enable ='On';
handles.edit1.Enable = 'On';
handles.edit9.Enable = 'On';
c = 3.676;
if isnan(b)
warningMessage = sprintf('Length of Rod Taper is empty');
uiwait(errordlg(warningMessage));
handles.edit2.String = 'Length of Rod Taper is empty'
return;
end
elseif listboxNumber == 1
handles.listbox2.Enable ='On';
handles.edit1.Enable = 'On';
handles.edit9.Enable = 'On';
c = 2.904;
if isnan(b)
warningMessage = sprintf('Length of Rod Taper is empty');
uiwait(errordlg(warningMessage));
handles.edit9.String = 'Length of Rod Taper is empty'
return;
end
elseif listboxNumber == 0.875
handles.listbox2.Enable ='On';
handles.edit1.Enable = 'On';
handles.edit9.Enable = 'On';
c = 2.224;
if isnan(b)
warningMessage = sprintf('Length of Rod Taper is empty');
uiwait(errordlg(warningMessage));
handles.edit9.String = 'Length of Rod Taper is empty'
return;
end
elseif listboxNumber == 0.75
handles.listbox2.Enable ='On';
handles.edit1.Enable = 'On';
handles.edit9.Enable = 'On';
c = 1.634;
if isnan(b)
warningMessage = sprintf('Length of Rod Taper is empty');
uiwait(errordlg(warningMessage));
handles.edit9.String = 'Length of Rod Taper is empty'
return;
end
elseif listboxNumber == 0.625
handles.listbox2.Enable ='On';
handles.edit1.Enable = 'On';
handles.edit9.Enable = 'On';
c = 1.135;
if isnan(b)
warningMessage = sprintf('Length of Rod Taper is empty');
uiwait(errordlg(warningMessage));
handles.edit9.String = 'Length of Rod Taper is empty'
return;
end
end
%c = str2double(c);
% Do the multiplication.
d = b * c;
% Send the result into edit field 3.
%handles.edit9.String = sprintf('%.f', d);
handles.edit9.String = num2str(d);
function edit9_Callback(hObject, eventdata, handles)
% hObject handle to edit9 (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 edit9 as text
% str2double(get(hObject,'String')) returns contents of edit9 as a double
t = str2double(handles.edit9.String);
if isnan(t)
tt =0;
else
tt =t;
end
%z = tt ;
handles.edit21.String = num2str(tt);
2 Kommentare
Akzeptierte Antwort
Aghamarsh Varanasi
am 18 Mär. 2021
Hi,
Try using the 'set' function to assign values in guide.
set(handles.edit21, 'String', num2str(tt));
Hope this helps
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!