code for a delete button in matlab gui

hello :) im doing a scientificcalculator GUI in Matlab, how can I code for a delete button for my calculator? its like deleting(just like backspace) characters from a static text box?

1 件のコメント

L.J.
L.J. 2015 年 12 月 2 日
編集済み: L.J. 2015 年 12 月 2 日

サインインしてコメントする。

 採用された回答

jaybee
jaybee 2012 年 9 月 30 日
編集済み: jaybee 2012 年 9 月 30 日

0 投票

could you make it simplier? im a starter in gui making.

4 件のコメント

Matt J
Matt J 2012 年 9 月 30 日
Simpler in what way? Which of the 3 steps I outlined don't you know how to do? Hopefully, step 2 was straightforward enough. I gave you a direct example.
jaybee
jaybee 2012 年 9 月 30 日
function pushbutton20_Callback(hObject, eventdata, handles)
screen = get(handles.text1, 'String');
screen = strcat( screen );
set( handles.text1, 'String', fprintf('%f\b\n', screen))
itried this but it failed, what should i edit here?
Matt J
Matt J 2012 年 9 月 30 日
screen = get(handles.text1, 'String');
screen(end)='';
set( handles.text1, 'String', screen)
jaybee
jaybee 2012 年 9 月 30 日
thankyou so much matt j :)

サインインしてコメントする。

その他の回答 (2 件)

Jan
Jan 2012 年 9 月 30 日

2 投票

Care for the empty input also:
screen = get(handles.text1, 'String');
if ~isempty(screen)
screen(end)='';
set(handles.text1, 'String', screen);
end

1 件のコメント

jaybee
jaybee 2012 年 10 月 1 日
thanks this would also help :)

サインインしてコメントする。

Matt J
Matt J 2012 年 9 月 30 日

0 投票

In the callback for the delete button you would
(1) Read the string from the text box.
(2) Truncate the string like in the example below
(3) Write the truncated string back into the text box
>> str='myString'
str =
myString
>> str(end)='' %truncate
str =
myStrin

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

タグ

質問済み:

2012 年 9 月 30 日

編集済み:

2015 年 12 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by