Effacer les filtres
Effacer les filtres

How do I get the integer value from a edit box?

2 vues (au cours des 30 derniers jours)
Recap
Recap le 2 Avr 2016
Commenté : Image Analyst le 2 Avr 2016
The only way I know of getting the value of an edit box is getting it as a string. How do I assign it as an integer. My edit box input is '123'. How do I retrieve it and store and an integer. I tried the code below but it didnt work
widthBox=get(handles.edit5,'String');
ws = str2num(widthBox);

Réponse acceptée

Image Analyst
Image Analyst le 2 Avr 2016
Looks like it should work. Why do you say it doesn't?
  3 commentaires
Recap
Recap le 2 Avr 2016
Its ok now, im using str2double and it seems to do the job.
Image Analyst
Image Analyst le 2 Avr 2016
perhaps it's a cell, which might happen if you have the max property set to bigger than 1. So try to use char() or cell2mat() to cast it to a character.
editBoxContents = get(handles.edit5,'String');
ws = str2double(char(editBoxContents));
% or
ws = str2double(cell2mat(editBoxContents));

Connectez-vous pour commenter.

Plus de réponses (0)

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!

Translated by