Help please simulation of gibbs sampling isempty function?
Mostrar comentarios más antiguos
i make a simulation to a gibbs sampling algorithm and the following code is part of the simulation :
mamodel=@(x)find(ismember(x(:,2:end),[1 0 0 0 0],'rows'))
if~isempty(a)
macount=a(mamodel(a),:)
else
macount=zeros(1,size(a,2))
end
h(i,:)=(macount)
the first line is to find a certain row from simulation results the problem is when this row is not in the results the smulation stops because the result is Empty matrix: 0-by-6 , i tried isempty function and also the simulation stops!! i want to make the simulation ignore the results and continue to next step
1 comentario
Walter Roberson
el 10 de Feb. de 2013
Respuestas (1)
Walter Roberson
el 10 de Feb. de 2013
0 votos
When I look at your anonymous function it appears to me that it could potentially return a variable number of results, leading to macount being an array rather than a column vector. You would then get a dimension mismatch when assigning it to h(i,:)
Since you need a result which is the same number of rows as h has, use zeros(1,size(h,2)). Unless, that is, you did not predefine h, in which case for your first execution, you would not have an "h" to take the size of.
Categorías
Más información sobre Entering Commands en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!