How to convert a string to int
Ältere Kommentare anzeigen
hi
in my script i got this
function [] = N_call(src,evendata)
% Callback for secondary GUI editbox.
S = get(0,'userdata');
%set(S.ed2,'string',get(gcbo,'string')) % Set gui_passdata editbox string.
str13=get(src,'string');
if (isempty(str2num(str13)))
set(src,'String','0')
else
n=str13;
save n
set(S.ed13,'string',get(gcbo,'string')) % Set gui_passdata editbox string.
end
and it saves to workspace as a string i guess, it shows value='20' max-nothing min-nothing
and i've another function that need to use the value but like an int. for an example if i define a=2 in script it shows value=2 max=2 and min=2, and this is waht i want but i don't know how
i've tried to use str2num and double with no results
2 Kommentare
Sean de Wolski
am 6 Okt. 2011
str2double(get(src,'string')) doesn't work?
Nu9
am 7 Okt. 2011
Akzeptierte Antwort
Kategorien
Mehr zu String finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!