Structure array to array

2 次查看(过去 30 天)
Edward
Edward 2013-9-26
I have a structure
s(1).x = 5;
s(2).x = 6;
s(1).y = 1;
s(2).y = 8;
how can i convert this into an array of x values and an array of y values, preferably without using a for loop?
Im trying to plot(s(:).x, s(:).y) but it only plots one point hence why i ask.

回答(2 个)

Azzi Abdelmalek
Azzi Abdelmalek 2013-9-26
编辑:Azzi Abdelmalek 2013-9-26
s(1).x = 5;
s(2).x = 6;
s(1).y = 1;
s(2).y = 8;
plot([s.x],[s.y])

Andrei Bobrov
Andrei Bobrov 2013-9-26
plot([s.x], [s.y])

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by