Plotting struct with out first line
Show older comments
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 Comments
madhan ravi
on 9 Jan 2019
upload your struct as .mat file , post the complete error message
KSSV
on 9 Jan 2019
YOu should post the error.
KSSV
on 9 Jan 2019
dpreuben commented:
The error is as follows:
Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.
But I see brackets are properly balanced.
KSSV
on 9 Jan 2019
x = s.a(2,:) ;
y = s.b(2,:) ;
what does
whos x y
display?
@dpreuben: read these to know why your code does not work:
What size are the fields a and b? How do you want to join the multiple field values together: horizontally (as your code would seem to indicate)?
@KSSV: given that s is non-scalar (as stated in the question), what do you expect these to do?:
s.a(2,:)
s.b(2,:)
Did you try them with a non-scalar structure?
dpreuben
on 10 Jan 2019
Stephen23
on 10 Jan 2019
@dpreuben: according to your description so far:
- structure s has size 1801*921
- each of the fields of that structure a and b has size 1801*1.
That seems a bit of an unusual coincidence to me: why does the structure happen to have exactly the same number of rows as all of its fields do?
Please show us the output of these commands:
size(s)
size(s(1).a)
size(s(1).b)
madhan ravi
on 10 Jan 2019
Who‘s Micheal?
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.
Accepted Answer
More Answers (0)
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!