1.编写test函数

function [o,p,q,r] = test( n )%%%%%%%%%%%%%%%编写function test函数

%%%%%%%%%%%%%%%%%%%%%%test函数变量为n,返回值为o,p,q,r

o= 0;
p=0;
q=6;
r=128;
for i = 1:n
    o = o + i;
    p=p+1;
    q=q.*n
    r=r.^0.2
    

end


2.调用tset函数的main函数

clear all;
clear clc;
[a,b,q,r]= test(10)%%%%%%%%%%%%%%%%%%调用test函数n=10,a,b,q,r四个为n=10的test函数的返回值!



matlab基础:函数FUNCTION编写

相关文章: