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

1 次查看(过去 30 天)
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Random Number Generation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by