No result being displayed in Edit box

1 visualizzazione (ultimi 30 giorni)
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 Commenti
Avinav Kumar
Avinav Kumar il 16 Mar 2021
sum of value of edit 9 and edit10 needs to be displayed in edit 21
Avinav Kumar
Avinav Kumar il 16 Mar 2021
even if we try to print edit9 value in edit21, its not hapenning.

Accedi per commentare.

Risposta accettata

Aghamarsh Varanasi
Aghamarsh Varanasi il 18 Mar 2021
Hi,
Try using the 'set' function to assign values in guide.
set(handles.edit21, 'String', num2str(tt));
Hope this helps

Più risposte (0)

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by