No result being displayed in Edit box
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Avinav Kumar
le 16 Mar 2021
Réponse apportée : Aghamarsh Varanasi
le 18 Mar 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 commentaires
Réponse acceptée
Aghamarsh Varanasi
le 18 Mar 2021
Hi,
Try using the 'set' function to assign values in guide.
set(handles.edit21, 'String', num2str(tt));
Hope this helps
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!