How can I save my results of a loop in one table

조회 수: 5 (최근 30일)
Mustafa Vural
Mustafa Vural 2020년 9월 16일
댓글: Star Strider 2020년 9월 17일
I have 25 parameter combination in my code (b&T --> 1:5).
In the third part of my code I am doing the anderson darling test on my combinations.
It tells me if ONE combination ( for example b=1 and T=1) is a good combination or bad. I want to see the results for all 25 combination. But with this code, I only see the last combination of the loop.
How can I save them all in a table?
clear all;
n = 10;
t0 = 0.5;
b = 1:5;
T = 1:5;
for v_T= 1:length(T)
for v_b= 1:length(b)
data(:,v_b,v_T) = wblrnd(v_b,v_T, [n,1]) + t0;
start = [1 0 0];
custompdf = @(x,a,b,c) (x>c).*(b/(a-c)).*(((x-c)/(a-c)).^(b-1)).*exp(-((x-c)/(a-c)).^b);
opt = statset('MaxIter',1e3,'MaxFunEvals',1e3,'FunValCheck','off');
params(v_b,1:3,v_T) = mle(data(:,v_b,v_T),'pdf',custompdf,'start',start,'Options',opt,'LowerBound',[0 0 0],'UpperBound',[Inf Inf Inf])
end
end
for v_T= 1:length(T)
for v_b= 1:length(b)
T_A = T(v_T)
b_A = b(v_b)
dist = makedist('weibull','a',T_A,'b',b_A)
[h,p] = adtest(data(:, v_b, v_T),'Distribution',dist)
end
end

채택된 답변

Star Strider
Star Strider 2020년 9월 16일
The adtest function returns scalars for the outputs, so something like this could work:
[h(v_b, v_T),p(v_b, v_T)] = adtest(data(:, v_b, v_T),'Distribution',dist);
That will save the results in their respective matrices.
I cannot run your code, so I cannot test that.
  댓글 수: 14
Mustafa Vural
Mustafa Vural 2020년 9월 17일
It looks really good, I really appreciate it. Thank you, you helped me a lot.
Star Strider
Star Strider 2020년 9월 17일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by