继续学习matlab

Problem 2867. Matlab Basics - Rounding III

function y = round_ten_thou(x)
  y =round(x,-4) ;
end

Problem 2866. Matlab Basics - Rounding II

function y = round_3_d_p(x)
  y =round(x,3) ;
end

Problem 2559. Check that number is whole number

function y = your_fcn_name(x)
for i=1:length(x)
    if rem(x(i),1)==0
        x(i)=1;
    else
        x(i)=0;
    end
end
y=x;
end

Problem 42644. MATLAB Basic: rounding IV

function y = round_x(x)
  y = ceil(x);
end

Problem 42643. MATLAB Basic: rounding III

function y = round_x(x)
  y = floor(x);
end

Problem 42642. MATLAB Basic: rounding II

function y = round_x(x)
  y = round(x);
end

Problem 42641. MATLAB Basic: rounding

function y = round_zero(x)
  y = fix(x);
end

Problem 2022. Find a Pythagorean triple

function flag = isTherePythagoreanTriple(a, b, c, d)
  flag = any(a^2+b^2==d^2|a^2+c^2==d^2|c^2+b^2==d^2|a^2+b^2==c^2);
end

Problem 2021. Is this triangle right-angled?

function flag = isRightAngled(a, b, c)
flag=any(a^2+b^2==c^2);
end

Problem 2019. Dimensions of a rectangle

function [width, length] = findRectangleDimensions(x)
width = x/sqrt(10);
length= width*3;
end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值