📄 07-23.txt
字号:
function meters = convert2meters(miles, varargin)
% Converts MILES (plus optional FEET and INCHES input)
% values to METERS.
if nargin < 1 || nargin > 3
error('1 to 3 input arguments are required');
end
function feet = convert2Feet(argsIn)
% Nested function that converts miles to feet and adds in
% optional FEET argument.
feet = miles .* 5280;
if argsIn >= 2
feet = feet + varargin{1};
end
end % End nested function convert2Feet
function inches = convert2Inches(argsIn)
% Nested function that converts feet to inches and adds in
% optional INCHES argument.
inches = feet .* 12;
if argsIn == 3
inches = inches + varargin{2};
end
end % End nested function convert2Inches
feet = convert2Feet(nargin);
inches = convert2Inches(nargin);
meters = inches .* 2.54 ./ 100;
end % End primary function convert2meters
feet = convert2Feet(nargin);
inches = convert2Inches(nargin);
meters = inches .* 2.54 ./ 100;
end % End primary function convert2meters
>> convert2meters(5)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -