Syntax on GUI calculator

조회 수: 3 (최근 30일)
Portgas Ace
Portgas Ace 2012년 10월 2일
i have this syntax for getting factorial in my calcu.
x = get(handles.edit1,'String');
y = str2num(x);
z = factorial(y);
j='!';
k=strcat(x,j);
set(handles.edit1,'string',k);
set(handles.text1,'String',z);
my problem is that. i want to do MDAS of factorial. like 5! + 6!. when i click the calcu as it is. it evaluates 5! but when i start to press + and 6!, the value that appears in text1 doesnt seem to be right, although edit1 shows 5! + 6!.

답변 (2개)

Walter Roberson
Walter Roberson 2012년 10월 2일
When you str2num() of '5!+6!', the result will be an empty string, as MATLAB will not be able to understand that string as a number. You will need to break it into pieces and figure out what to do with the pieces.

Azzi Abdelmalek
Azzi Abdelmalek 2012년 10월 2일
z=factorial(x)
set(handles.text1,'String',z);
% is not correct, z is not a string

카테고리

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