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

1 visualización (últimos 30 días)
Mustafa Vural
Mustafa Vural el 16 de Sept. de 2020
Comentada: Star Strider el 17 de Sept. de 2020
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

Respuesta aceptada

Star Strider
Star Strider el 16 de Sept. de 2020
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 comentarios
Mustafa Vural
Mustafa Vural el 17 de Sept. de 2020
It looks really good, I really appreciate it. Thank you, you helped me a lot.
Star Strider
Star Strider el 17 de Sept. de 2020
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Random Number Generation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by