Filter löschen
Filter löschen

Retrieving Arrays Within Set of Matrices

16 Ansichten (letzte 30 Tage)
Samuel
Samuel am 4 Jul. 2024 um 21:39
Bearbeitet: Voss am 4 Jul. 2024 um 22:18
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!

Antworten (1)

Voss
Voss am 4 Jul. 2024 um 22:17
Bearbeitet: Voss am 4 Jul. 2024 um 22:18
x = M{1,4}(:,1);
C = cellfun(@(m)m(:,2),M(:,4),'UniformOutput',false);
y = [C{:}];
plot(x,y)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by