How do I use the random function in Fsolve Matlab?
Ältere Kommentare anzeigen
Hello everyone,
In the following codes, I am trying to determine the variable x that lets beta equal target beta. This does not work for me when I use fsolve. Could anyone please take a look at it and help me with that?
Thank you so much!
% example
clear
clc
% define values
n = 1e4;
target_beta = 2;
x = 2; % predefine x
% parameters
Mean_R = 2000 ; %mean
CoV_R = 0.1;%coefficient of variation
Std_R = Mean_R * CoV_R;
% Monte Carlo Simulation
Ri = Mean_R + Std_R .* norminv(rand(n, 1));
Mean_Q = x * 1100; % Determine which variable, x, will let the beta = target beta
CoV_Q = 0.18;
Std_Q = Mean_Q * CoV_Q;
Qi = Mean_Q + Std_Q .* norminv(rand(n, 1)); % simuate the Q term
g = Ri - Qi; % limit state function g = R - Q
m = find(g < 0); % count the number of failure cases
f = length(m); % find the failure cases number in the g = R-Q vector
pr_failure = f / n; % probability of failure
beta = norminv(1 - pr_failure); %Calculate the reliability index beta
% fsolve
alpha = fsolve(@(x) (beta-target_beta),2)
Akzeptierte Antwort
Weitere Antworten (1)
Priyanka Kondapalli
am 22 Mär. 2022
Bearbeitet: Priyanka Kondapalli
am 24 Mär. 2022
0 Stimmen
Hi,
I do not see any issue with the code provided by you.However, recheck the equation. Please refer to the link below which provides more details on how to use Fsolve.
Kategorien
Mehr zu Linear Programming and Mixed-Integer Linear Programming finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!