MATLAB Answers

0

How to call data from a structure?

Asked by John Hunt on 4 Oct 2017
Latest activity Edited by James Tursa
on 4 Oct 2017
I have a structure that is 1x36. Each of the cells has data that I would like to call and use. How can I do that?

  0 Comments

Sign in to comment.

Tags

1 Answer

Answer by James Tursa
on 4 Oct 2017
Edited by James Tursa
on 4 Oct 2017
 Accepted Answer

How do you want to use it? If you are talking about the results of your last Question, it is a "cell array" and not a "structure". Those are two different things in MATLAB. To use a cell array, just use the curly braces { } instead of parentheses ( ) when you are indexing. I.e.,
result = the cell array from your last question
:
... result{1} ... <-- some expression involving the first matrix from the result
etc
Note I used {1} instead of (1). The second matrix would be result{2}, etc.
E.g., suppose you wanted to add 2 to the third column of the 5th matrix. Then it would be:
result{5}(:,3) = result{5}(:,3) + 2;

  0 Comments

Sign in to comment.