# Retrieving Arrays Within Set of Matrices

1 view (last 30 days)
Samuel on 4 Jul 2024
Edited: Voss on 4 Jul 2024
Hello,
I have several sets of data that I want to plot on one graph. The problem is that each data set is in its own matrix. For instance, I have a 36x4 matrix (let's call it M). In each of the cells in the 4th column is a 516x2 matrix, corresponding to x and y values. The x values are the same for each of the 516x2 matricies, so I just want to plot the y values against one set of x values. I try to make an additional matrix (let's call it N) to have the y values all side by side by using the following code
N=[M{:,4}(:,2)]
But then I get the following error
Intermediate brace '{}' indexing produced a comma-separated list with 36 values, but it must produce a single value when followed by subsequent indexing operations.
The end goal is to be able to use this after iterative peak fitting across multiple similar data sets, but I need to be able to efficiently visualize the resulting plots. I would be grateful for any help on this. Thank you!

Voss on 4 Jul 2024
Edited: Voss on 4 Jul 2024
```x = M{1,4}(:,1);
```
```C = cellfun(@(m)m(:,2),M(:,4),'UniformOutput',false);
y = [C{:}];
```
```plot(x,y)
```