0% found this document useful (0 votes)
6 views4 pages

Code Kim

The document contains MATLAB code for three different tasks. The first task involves plotting a quadratic function, the second task calculates and plots reliability over time using exponential decay functions, and the third task computes and visualizes the Unit Energy Cost (UEC) based on a Weibull distribution. Each section includes initialization of parameters, calculations, and plotting of results.

Uploaded by

mybeo0763
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

Code Kim

The document contains MATLAB code for three different tasks. The first task involves plotting a quadratic function, the second task calculates and plots reliability over time using exponential decay functions, and the third task computes and visualizes the Unit Energy Cost (UEC) based on a Weibull distribution. Each section includes initialization of parameters, calculations, and plotting of results.

Uploaded by

mybeo0763
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Bài 1.

2: Thực hiện code


%Viet chuong trinh matlab
clc
clear all
a = 17;
b = 10;
c = 11;
x = -10:0.1:10;
y = a*x.^2 + b*x + c;
figure(1)
plot(x,y)
GTNN = min(y);
e = exp(1);
Bài 2:

clc;
clear all;
close all; % Ðóng tat ca figure de tránh xung ðot

% Khoi tao các thông so


psd1 = 0.002;
psd2 = 0.002;
lu = 0.001;
cb1 = 0.003;
cb2 = 0.003;
psv1 = 0.001;
psv2 = 0.001;
rd = 0.001;

% Tao vector thoi gian


t = 0:250;
%Khoi tao cac ham`
Rpsd1 = exp(-psd1 * t);
Rpsd2 = exp(-psd2 * t);
Rpsv1 = exp(-psv1 * t);
Rpsv2 = exp(-psv2 * t);
Rcb1 = exp(-cb1 * t);
Rcb2 = exp(-cb2 * t);
Rlu = exp(-lu * t);
Rrd = exp(-rd * t);

Ra = 1 - (1 - Rpsd1) .* (1 - Rpsd2);
Rb = 1 - (1 - Rpsv1) .* (1 - Rpsv2);
Rc = 1 - (1 - Rcb1) .* (1 - Rcb2);

% Bieu thuc ham do tin cay


Rs = 1 - (1 - Ra .* Rlu .* Rc) .* (1 - Rb) .* (1 - Rrd);

% Ve ðo thi
figure(2);
plot(t, Rs, 'b', 'LineWidth', 1.5);
xlabel('Time t');
ylabel('Value Rs');
title('Bieu do Rs theo thoi gian');
grid on;
% Giá tri nho nhat cua Rs
GTNN = min(Rs);
disp(['Giá tr? nh? nh?t c?a Rs: ', num2str(GTNN)]);

% Tim giá tri Rs tai t = 50


t_target = 70; %tùy ch?nh
idx = find(t == t_target); % Tim vi trí cua t = 50 trong
vector t
Rs_at_50 = Rs(idx); % L?y giá tr? Rs t?i t = 50
disp(['Giá tri Rs tai t = 70: ', num2str(Rs_at_50)]);

Câu 3:
clc
clear all
beta = 2.1;
theta = 1531.4;
Cp = 1000;
stt = 6;
Cf = (3 + stt/20)*Cp;
f = @(t)1-wblcdf(t,theta,beta);

tp = 500:2000;
UEC = zeros(1,length(tp));
inte = zeros(1,length(tp));
for i=1:length(tp)
inte(i) = integral(f,0,tp(i));
R = 1-wblcdf(tp(i),theta,beta);
F = wblcdf(tp(i),theta,beta);
UEC(i) = (Cp*R+Cf*(1-R))/(inte(i));
end
b = min(UEC);
Opt_tp = find(UEC==b);
Optimaltp=tp(Opt_tp);
plot(tp,UEC,'linewidth',1.5)
hold on
plot(tp(Opt_tp),b,'*','linewidth',2.5)
title('Ve ham UEC(tp)')
xlabel('tp(h)')
ylabel('UEC($/h)')
grid on
set(gca,'Fontsize',12,'linewidth',1.5)

You might also like