Assuming the domain is x
and the comparison parameter is b
we can loop through the values of b
to create three distinct vectors for which the function, f
is plotted for. Here the value of b
is swapped on each iteration of the for-loop. The resultant end up being f
with 3 rows by 4 columns where the columns correspond to the x-values/domain and the rows correspond to the value of parameter, b
.
x = (0:3);
a = 1;
B = [1 2 3.5];
for Parameter_Index = 1: length(B)
b = B(Parameter_Index);
f(Parameter_Index,:) = (a.*b.*x).^(b-1).*exp(-a.*x.^b);
end
plot(x,f(1,:),x,f(2,:),x,f(3,:));
xlabel("x"); ylabel("f(x)");
legend("B = " + num2str(B(1)),"B = " + num2str(B(2)),"B = " + num2str(B(3)));
Ran using MATLAB R2019b
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…