MATLAB Programming--Write MATLAB Function

Write MATLAB functions

Write a script to ask the price to solve the above averaging problem:

function aver = myaver(x,n)
sizex = size(x);
sizen = size(n);
if sizex(2)~=sizen(2)
    disp('数组维数不相同');
else
    total = sum(n);
    s = sum(x.*n);
    ave = s/total
end

Regarding the final return value, if there is a semicolon behind, the output result is not displayed, otherwise it is displayed.

Published 84 original articles · won 18 · views 5805

Guess you like

Origin blog.csdn.net/qq_44486550/article/details/105315909