How can I select items in a double list?
Show older comments
Hi everyone!
I have a variable which is (105 x 1 double) and I need to select from the first item to 3rd, from 4th item to 6th and from 7th item to 9th.
When, for instance, I apply:
TA8=T_C((1:3):1)
Only appears the first element and not the 2nd and 3rd ones.
How can I show the three elements?
Thank U
Accepted Answer
More Answers (1)
Image Analyst
on 14 Jun 2019
Try
TA8 = T_C(1:3);
etc. Or for all of them in turn:
for k = 1 : 3 : length(T_C) % Starting at 1, 4, 7, etc....
TA8 = T_C(k:k+2); % Get this group of 3 elements.
% Now do something with TA8
end
6 Comments
Jonathan Bijman
on 14 Jun 2019
Jonathan Bijman
on 14 Jun 2019
Image Analyst
on 14 Jun 2019
Attach a .mat file with the paper clip icon that has your variable in it.
I guess we really don't know what you want. Do you want extractions of 3 elements at a time like you asked for, and we gave you, or do you want something else? Please show, with a numerical example of say an input vector of 12 elements, exactly what you want as the output.
Jonathan Bijman
on 14 Jun 2019
Image Analyst
on 14 Jun 2019
Sounds like, from your comment to Walter, that you've got it all solved now, so there is no need for me to answer anymore.
Jonathan Bijman
on 14 Jun 2019
Categories
Find more on Creating, Deleting, and Querying Graphics Objects 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!