Field text- number

조회 수: 1 (최근 30일)
john
john 2012년 3월 14일
Hi,
if I write integer number like 4 into field text, thens it is ok.
But when I write floating number like 4.5 into field text, then write error...
How can I do this?
Thanks
  댓글 수: 2
Aldin
Aldin 2012년 3월 14일
Do you work in MATLAB GUI?
Aldin
Aldin 2012년 3월 14일
I don't know but i quess this is what you want:
set(handles.edit1,'String',num2str(4.5));

댓글을 달려면 로그인하십시오.

채택된 답변

Aldin
Aldin 2012년 3월 14일
I have tested my code:
set(handles.edit1,'String',num2str(4.5));
It's correct.
  댓글 수: 25
Aldin
Aldin 2012년 3월 20일
Here is on maybe better solution: use *find* function.
For example if you have string like this:
>>string = '453,45434';
you can use *find* function you have to check if there in string exist comma: find(string==',') the result will be 4.
Now, if you have string like this: >>string = '4534434' (without comma) the result for _find(string==',')_ will be Empty matrix: 1-by-0. I hope my advice will be helpful
john
john 2012년 3월 20일
Great idea, find(string==',') is very helpfull, thank yuo again

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by