2

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));

2 Answers 2

1

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
Sign up to request clarification or add additional context in comments.

Comments

1

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]

2 Comments

How does this differ from my answer?
Im using a generic size(Result) instead of numbers for the reshape, otherwise it's the same idea. I din't see your answer on time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.