How to sit a fixed value of k with an array of θ values, or a fixed value of θ with an array of k values?

1 vue (au cours des 30 derniers jours)
Hi, I am trying to calculate the Weibull Distribution.
this is the question...
The Wiebull distribution can be used in analysing failure rates, wind speed distributions, etc. where the shape factor, k >0, and the scale factor, λ >0, characterise the distribution profile. An example distribution is shown in the figure below. Write a MATLAB script which calculates the Wiebull distribution as it varies with either the scale or shape parameter; i.e. if varying in scale, use a fixed value for the shape parameter and vice versa. Your script should also plot the distribution.
This is the equation that we are supposed to use:
This is a sample input screen
This is what i have done so far however, I am not sure about what to do next?
clc;
clear;
fprintf('Please enter the minimum value, maximum value and increment value for x (where x is the x axis) ... \n\n')
min = input('Minimum x value (>0): ');
max = input('Maximum x value (> min value): ');
inc = input('Step increment for the x axis : ');
if min > max
fprintf('The maximum x value you have entered was smaller than the minimum x value, please enter another one.\n')
end
if min < 0
fprintf('The minimum x value should be greater or equal to 0, please enter another one.\n')
end
if inc > (max-min)
fprintf('please enter another increment value, where inc < (max - min)\n')
end
thanks

Réponses (1)

Asvin Kumar
Asvin Kumar le 17 Jan 2020
A simple way of checking whether your conditions are met would be by using the modified code given below:
flag = 0;
while ~flag
fprintf('Please enter the minimum value, maximum value and increment value for x (where x is the x axis) ... \n\n')
min = input('Minimum x value (>0): ');
max = input('Maximum x value (> min value): ');
inc = input('Step increment for the x axis : ');
if min > max
fprintf('The maximum x value you have entered was smaller than the minimum x value, please enter another one.\n')
elseif min < 0
fprintf('The minimum x value should be greater or equal to 0, please enter another one.\n')
elseif inc > (max-min)
fprintf('please enter another increment value, where inc < (max - min)\n')
else
flag = 1;
end
end
Another approach to this would be to use assert. Have a look at it's documentation here: https://www.mathworks.com/help/matlab/ref/assert.html
To display a family of Weibull PDFs you can adapt the following code.
x = min:inc:max;
figure
hold on
A = 5;
for B = 0.1:0.1:2
y = wblpdf(x,A,B);
plot(x,y,'DisplayName',strcat("B = ",string(B)));
end
title(strcat("A = ",string(A)))
legend
figure
hold on
B = 2;
for A = 0.5:0.5:10
y = wblpdf(x,A,B);
plot(x,y,'DisplayName',strcat("A = ",string(A)));
end
title(strcat("B = ",string(B)))
legend
You would see the following plots:
weibullA.png
weibullB.png

Tags

Produits


Version

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by