我试图测量构造函数创建已在其自己的类中定义的对象所需的时间。
我怎么能在matlab中做到这一点?
非常感谢。
这里是班级
classdef randv
%To create a random vector that fit into the basics requirement
% Random vector that fits into basic requirements and
% compute the froud number
properties(GetAccess=public, SetAccess=protected)
x1
x2
x3
x4
valid
fr
d_i
dd_i
delta_i
end
methods
function j=randv()
x1=(75-50).*rand(1)+50;
x2=(15-10).*rand(1)+10;
x3=(7.7-5.7).*rand(1)+5.7;
x4=(24.2-18.1).*rand(1)+18.1;
while ((x1/x2 >= 4.7 && x1/x2 <= 6.5 && x2/x3<= 2) == 0)
x1=(75-50).*rand(1)+50;
x2=(15-10).*rand(1)+10;
x3=(7.7-5.7).*rand(1)+5.7;
x4=(24.2-18.1).*rand(1)+18.1;
end
j.x1=x1;
j.x2=x2;
j.x3=x3;
j.x4=x4;
j.valid=1;
j.fr=5.15/sqrt(9.81*j.x1);
j.d_i=x2/x3;
j.dd_i=x1/x4;
j.delta_i= 1*0.72*x1*(x2^2/x3);
end
end
端
谢谢