Programatically getting contents from an edit box.
1 view (last 30 days)
Show older comments
sorry to raise another thread, I had previously closed with an accepted answer, but this was by mistake. I have tried all suggestions but not getting this to work, even with the handles.figure1 suggestion. To simplify, I programmatically create a checkbox and edit box via:
checkboxCumsum= uicontrol('Style', 'checkbox',...
'String', {'Cum Sum'},...
'Position', [620 0 80 30],...
'Callback', @(src,evt) CumSum( src, evt, ax1,handles.figure1 ));
edx = uicontrol('Style', 'edit',...
'String', {'95'},...
'Position', [700 5 40 20]);
I then create a function Cumsum as:
function CumSum(source,event,ax,handles)
val = source.Value
h=getappdata(0,'histog') %previously drawn histogram
if val==1
hline = findall(gca, 'type', 'line');
delete(hline);
counts=h.Values;
edges=h.BinEdges;
width=h.BinWidth;
ctrs=edges(1:end-1)+width/2;
%integrate histogram using cumsum
cs=cumsum(counts)
l=cs(end)
l1=0.95*l
[ii]=find(cs>l1)
ct=ctrs(ii(1))
hold on
lineH1=plot([ct ct],ylim,'b--','LineWidth',0.7);
text(ct+5,0.90*max(ylim), ['CumSum95=',num2str(ct,'%.0f')],'Fontsize',8,'Color','k','FontWeight','normal')
hold off
x=str2num(get(handles.edx,'String'))
end
I still get the error
No appropriate method, property, or field 'edx' for class 'matlab.ui.Figure'.
3 Comments
Answers (0)
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!