Reputation: 571
Let's say I have this structure:
Results(i,j).fo
Results(i,j).co
where i=19
and j=30
. How can I save in a ixj
matrix all Results(i,j).fo
? Or even better, How can I say to bootci
to read only 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));
Upvotes: 2
Views: 72
Reputation: 1905
Given an array of equivalent structures, e.g.
Results = [ struct('fo',1, 'co',2) struct('fo',10, 'co',20); struct('fo',100, 'co',200) struct('fo',1000, 'co',2000) ]
You can access all 'fo` using the square brackets
all_fo = [Results.fo]
% >> [1 100 10 1000]
However, they are then in a 1D-array, to get them in the original format, use
all_fo = reshape([Results.fo], size(Results))
% >> [1 10; 100 1000]
Upvotes: 1
Reputation: 45752
I think this should work for your first question:
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)
Now
reshape([A.x], 3,3)
ans =
1 4 7
2 5 8
3 6 9
and
reshape([A.y], 3,3)
ans =
8 5 2
7 4 1
6 3 0
Upvotes: 1