How can I stop uicontrol from changing my scalar input to a vector?

1 view (last 30 days)
I am building a GUI and have noticed that a few of my inputs have been converted from a scalar into a vector by a uicontrol function. Here is a sample code which shows that my scalar input being transformed into a vector matrix:
clc
fig=figure('Visible','on','Menu','none','Resize','off','NumberTitle','off','Name',...
'test3','Position',[50 50 500 500],'color',[0.7 0.7 0.7]);
x = 100
value_x = x
size_x = size(x)
scalar_x = isscalar(x)
hx = uicontrol('String',x,'Tag','x','Style','edit','Parent',fig,'Position',[100 192 40 15]);
value_hx = get(hx,'String')
size_hx = size(get(hx,'String'))
scalar_hx = isscalar(get(hx,'String'))
Any ideas on how to stop or work around this?
Thanks in advance for your help!

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 22 Sep 2013
Edited: Azzi Abdelmalek on 22 Sep 2013
a=get(hx,'String') % is char
b= str2double(a) % convert to double
isscalar(b)

More Answers (0)

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!