Output vector from structure

2 visualizaciones (últimos 30 días)
Ro Sch
Ro Sch el 7 de Oct. de 2021
Respondida: Image Analyst el 7 de Oct. de 2021
I have saved some data in a structure in the following way:
driver(1).status = 1;
driver(2).status = 3;
driver(3).status = 4;
driver(1).position = 7;
driver(2).position = 4;
driver(3).position = 2;
What I would like to do now is get a vector of the driver.status for example, so receive a vector that says [1,3,4].
When I use the command driver.status, I however get the following output:
ans =
1
ans =
3
ans =
4
I have not found any way so far how to tell Matlab what I want, I am sure there is some function or way of calling the variable but I haven't found that yet. Thanks for your help!

Respuesta aceptada

KSSV
KSSV el 7 de Oct. de 2021
[driver(:).status]

Más respuestas (1)

Image Analyst
Image Analyst el 7 de Oct. de 2021
Try this:
vec = [driver.status]

Categorías

Más información sobre Structures en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by