Plotting struct with out first line

10 vues (au cours des 30 derniers jours)
dpreuben
dpreuben le 9 Jan 2019
Commenté : dpreuben le 22 Jan 2019
Hi,
I have struct with 1801 X 921 elemants. I want to plot certain fields without the first row
so for example, if I use the following,
plot ([s.a(2,:)], [s.b(2,:)]);
it is giving error
can you please help me on this. Thanks.
  12 commentaires
Stephen23
Stephen23 le 10 Jan 2019
Modifié(e) : Stephen23 le 10 Jan 2019
The structure has size 1801*1, and its first element's a and b fields contain arrays with sizes 1*1 and 1*4 respectively. This means that both a and b have exactly one row, so what you ask in your question does not make sense: "I want to plot certain fields without the first row". What data do you want to get from non-existent rows?
Possibly other elements of s have fields with more than one row, but you would still need to explain if single rows (like the ones you have shown) should be ignored, or throw an error, or whatever you need. Please upload the structure in a .mat file by clicking the paperclip button.
dpreuben
dpreuben le 22 Jan 2019
Modifié(e) : dpreuben le 22 Jan 2019
Please find the matlfile attached. My aim is to plot s.a vs s.b

Connectez-vous pour commenter.

Réponse acceptée

Stephen23
Stephen23 le 22 Jan 2019
  3 commentaires
Stephen23
Stephen23 le 22 Jan 2019
Modifié(e) : Stephen23 le 22 Jan 2019
Whoever created that structure placed some character vectors (apparently the units of the numeric data) in the first element of s, i.e.:
  • s(1).a contains the char vector 's' (which has size 1x1).
  • s(1).b contains the char vector 'kg/h' (which has size 1x4).
All the rest of the data are numeric scalar. You could have easily found this out yourself, by looking at the data itself in the Variable Viewer. Or you could have looked at my answer, where I use those character vectors as the axes labels.
This is certainly an innovative way to store that data, but not a very efficient or clear (the numeric data would be efficiently stored in numeric arrays, and the units in their own fields).
Please remember to accept my answer!
dpreuben
dpreuben le 22 Jan 2019
Thanks a lot Stephen.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Structures dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by