extract Object properties from cell array

6 ビュー (過去 30 日間)
Doctor G
Doctor G 2015 年 3 月 4 日
回答済み: Guillaume 2015 年 3 月 4 日
I have a cell array where each cell is a .NET object called Centroid. It has the following structure.
u.centers{:}
ans =
Centroid with properties:
x: 112.5769
y: 29.5762
count: 1250
strength: 12.3399
ans =
Centroid with properties:
x: 21.5000
y: 18.0690
count: 58
strength: 12.3400
I would like to plot the x,y values. How do I go about extracting the x and y values for a plot. This was my naive attempt:
plot(u.centers{:}.x, u.centers{:}.y, 'r.');

採用された回答

Guillaume
Guillaume 2015 年 3 月 4 日
This should work:
xy = cell2mat(cellfun(@(c) [c.x; c.y], u.centers, 'UniformOutput', false));
plot(xy(1, :), xy(2, :), 'r.')

その他の回答 (1 件)

Doctor G
Doctor G 2015 年 3 月 4 日
See figure above

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by