假设我有这种结构:
Results(i,j).fo
Results(i,j).co
其中i=19
和j=30
。如何在ixj
矩阵中保存所有Results(i,j).fo
?或者甚至更好,我怎么能说bootci
只读Results(i,j).fo
Media_tot = mean(Matrix,2)
ci = bootci(1000, @mean, Matrix');
ci = abs(ci' - repmat(Media_tot,1,2));
hE = errorbar(xdata_m, ydata_m, ci(:,1), ci(:,2));
答案 0 :(得分:1)
我认为这应该适用于您的第一个问题:
reshape([Results.fo], 19, 30)
e.g。
%// Make a 3x3 matrix of structs with 2 fields
A = [];
for k = 1:9
A(k).x = k;
A(k).y = 9-k;
end
A= reshape(A,3,3)
现在
reshape([A.x], 3,3)
ans =
1 4 7
2 5 8
3 6 9
和
reshape([A.y], 3,3)
ans =
8 5 2
7 4 1
6 3 0
答案 1 :(得分:1)
给定一组等效结构,例如
Results = [ struct('fo',1, 'co',2) struct('fo',10, 'co',20); struct('fo',100, 'co',200) struct('fo',1000, 'co',2000) ]
您可以使用方括号
访问所有'fo`all_fo = [Results.fo]
% >> [1 100 10 1000]
然而,它们是在一维数组中,以原始格式获取它们,使用
all_fo = reshape([Results.fo], size(Results))
% >> [1 10; 100 1000]