From a structure with "n" fields which each are a vector, I want to make a vector of length "n" made of the 3rd value of each vector of my structure.
3 views (last 30 days)
This is a situation I have come upon a few times now since I started using structures little time ago.
Specifically in the last case, I have a structure called "file" with 25 fields. On each field I have a vector called "dist" which is a simple 4 value vector. The thing is that I would like a vector with the 3rd value of each of these vectors, somthing like:
a = file(:).dist(4);
Which does not work at all.
I've discovered that if I write:
a = [file(:).dist];
I get a 1x100 vector with all the .dist vectors concatenated. Also, doing:
makes "a" into a 25x4 matrix in which each row is a .dist vector. However, I cannot index directly into that expression as:
I realise that I could get this with a little bit of code such as:
and even faster, with the vertcat function as:
But none of these solutions allow me to plot this directly, which is my ultimate goal, in this case.