编写matlab函数文件,输入参数a,b分别为矩形的长和宽,输出参数为矩形的面积m和周长n

如题所述

function [m,n]=Rectangle_statistics(a,b)
%输入变量为a,b分别为长和宽
%输出变量m,n分别为面积和周长
m=a*b;
n=2*a+2*b;
%%%调用时
a=?;
b=?;
%问号部分自己输入数字
[m,n]=Rectangle_statistics(a,b);
就可
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-06-24
a=input('长方形的长a=');
b=input('长方形的宽b=');
m=a*b;n=2*(a+b);
m=strcat('长方形的面积m=',int2str(m), m)
n=strcat('长方形的边长n=',int2str(n),n)
第2个回答  2011-06-24
function SRECT = SRECT(a,b)

switch(nargin)
case 1
SRECT = a*a;
case 2
SRECT = a*b;
otherwise
disp('请输入矩形的长和宽数据!');
end
本回答被提问者采纳