Results as a loop
조회 수: 1 (최근 30일)
이전 댓글 표시
I want to make my results as a loop.
When I change the parameter b_A or T_A from 1:5 to 1:3, I want that my results also change. But with this code, I need to change manually the result code, every time I change the loop of the parameter. Can someone help me plz?
This code is to estimate a 3 parameter weilbul distribution.
clear all
n = 1000;
t0 = 0.5;
b_A = 1:5;
T_A = 1:5;
LowerBound= [0 0 0];
rng('shuffle');
data = zeros(n,length(b_A),length(T_A));
params = zeros(length(b_A),length(T_A));
data2P = zeros(n,length(b_A),length(T_A));
params2p = zeros(length(b_A),4,length(T_A));
for k= T_A
for i= b_A
data(:,i,k) = wblrnd(i,k, [n,1]) + t0;
data2P(:,i,k) = wblrnd(b_A(i),T_A(k), [n,1]);
start = [i k t0];
custompdf = @(x,a,b,c) (x>c).*(b/a).*(((x-c)/a).^(b-1)).*exp(-((x-c)/a).^b);
opt = statset('MaxIter',1e5,'MaxFunEvals',1e5,'FunValCheck','off');
params(i,1:3,k) = mle(data(:,i,k),'pdf',custompdf,'start',start,'Options',opt,'LowerBound',LowerBound,'UpperBound',[Inf Inf min(data(:,i,k))])
params(i,4,k) = i;
params(i,5,k) = k;
params(i,6,k) = t0;
params2p(i,1:2,k) = wblfit(data2P(:,i,k));
params2p(i,3,k) = i;
params2p(i,4,k) = k;
end
end
result(1:5,:)= params(:,:,1);
result(6:10,:)= params(:,:,2);
result(11:15,:)= params(:,:,3);
result(16:20,:)= params(:,:,4);
result(21:25,:)= params(:,:,5);
댓글 수: 2
Image Analyst
2020년 6월 20일
If you don't want to change them by changing your code, how do you want to change them? Where would you change these values if not in your code? Do you want to make a list of the starting and stopping values in a text file or somewhere, that your code read in? Do you want your code to ask the user? I have no idea - you forgot to say.
답변 (1개)
KALYAN ACHARJYA
2020년 6월 21일
편집: KALYAN ACHARJYA
2020년 6월 21일
%Last section
data1=0;
results=[];
for i=1:length(T)
result(b+data1,:)= params(:,:,T(i));
data1=data1+5;
end
댓글 수: 2
KALYAN ACHARJYA
2020년 6월 21일
편집: KALYAN ACHARJYA
2020년 6월 21일
Thanks Madhan, sorry again, I missed the same. But, I have no idea about exact size of results, its depends on b, and author said it can be change any sizes.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!