Task 07 :第三章习题

Task 07 :第三章习题_第1张图片

y = inline('sin(x) / (1 + 3 * x + x * x)', 'x')

function Z = calcul(x1, x2, x3)
Z = x1 ^ 2 + 2 * x2 ^ 2 + 3 * x3 ^ 2 + 2 * x1 * x2 + 3 * x2 * x3 + 5 * x2 * x3;
% calcul(x1, x2, x3) is a design formulas
% The x1, x2, x3 must be number
% For example calcul(1, 1, 1)
%           ans = 
%               16
clc
clear
x = input('please input a number');
str = num2str(x);
for i = 1 ; length(str)
    r(i) = str2double(str(i));
end
if length(r) == 1
    disp('the answer is 0');
else
    for j = 2 ; length(r)
        s = find(r(1 : j - 1) > r(j))
        u(j) = length(s)
        result = sun(u)
    end
    disp('the ansser is');
    disp(result);
end

你可能感兴趣的:(Task 07 :第三章习题)