フィルターのクリア

Retrieving Arrays Within Set of Matrices

16 ビュー (過去 30 日間)
Samuel
Samuel 2024 年 7 月 4 日 21:39
編集済み: Voss 2024 年 7 月 4 日 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!

回答 (1 件)

Voss
Voss 2024 年 7 月 4 日 22:17
編集済み: Voss 2024 年 7 月 4 日 22:18
x = M{1,4}(:,1);
C = cellfun(@(m)m(:,2),M(:,4),'UniformOutput',false);
y = [C{:}];
plot(x,y)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by