设计视图:
代码视图
代码:
% Button pushed function: add
function addButtonPushed(app, event)
x=app.num1.Value;
y=app.num2.Value;
app.result.Value=x+y;
end
% Button pushed function: subtract
function subtractButtonPushed(app, event)
x=app.num1.Value;
y=app.num2.Value;
app.result.Value=x-y;
end
% Button pushed function: multiply
function multiplyButtonPushed(app, event)
x=app.num1.Value;
y=app.num2.Value;
app.result.Value=x*y;
end
% Button pushed function: divide
function divideButtonPushed(app, event)
x=app.num1.Value;
y=app.num2.Value;
app.result.Value=x/y;
end
运行结果: