convert 1x20 double struct into a vector containing 20 values
Mostrar comentarios más antiguos
I have a struct which is '1x20 double'
When I plot this, I get these 20 y-values plotted from x=1 to x=20
However, I need to be able to plot all of these values on the same x coordinate.
Nothing I do works because it is in a struct.
struct2table/struct2cell do not work.
3 comentarios
Kick Greven
el 1 de Feb. de 2023
Jan
el 1 de Feb. de 2023
"a 1x307 struct with 10 fields that I extracted 20 values from into a new variable via indexing." - Please note, that you might know, what this means, but a reader can have a faint idea aboud the corresponding procedure only. This is the hard part of asking question: considering that the readers know as much as a rubber duck about the problem while you hope, that they can solve it. :-)
Respuestas (1)
With wild guessing:
S.y = rand(1, 20); % Is this equivalent to your struct?
plot(S.y); % Is this the way your get a plot?
% And you want this:
x = 2;
figure;
plot(x, S.y, 'o')
Remember, that plot(x, S.y) without specifying the marker will not show anything, because lines appear only, if their length is greater than 0, what is not true for single points.
1 comentario
Kick Greven
el 1 de Feb. de 2023
Categorías
Más información sobre Structures en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

