Message Boards Message Boards

0
|
1450 Views
|
3 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Take elements in a list by some letters in the name

Hi, I have the following list :

{{"01-a-mas-480s.dat", {1.24, 1.52, 6.73, 4.04, 0.09, 2.4, 0.02, 
   0.03}}, {"01-b-mas-480s.dat", {1.09, 1.59, 15.9, 9.13, 0.61, 7.39, 
   0.07, 0.16}}, {"01-c-mas-480s.dat", {0.79, 0.96, 5.97, 3.34, 0.35, 
   2.66, 0.03, 0.05}}, {"02-a-mas-480s.dat", {0.77, 0.97, 4.68, 2.7, 
   0.35, 2.55, 0.03, 0.04}}, {"02-b-mas-480s.dat", {0.85, 1.23, 9.53, 
   4.76, 1.18, 5.82, 0.06, 0.11}}, {"03-a-mas-060s.dat", {7.84, 9.09, 
   38.35, 32.62, -0.05, 1.85, 0.2, 0.38}}, ect ect 

where {"01-a-mas-480s.dat", {1.24, 1.52, 6.73, 4.04, 0.09, 2.4, 0.02, 0.03}} is one set of data, with some parameters related to that name.
I would like to take from the first list only some elements, with some peculiarity on the name: For example only the sets of data with the "a", and only with "60s" in the name. How can I do it? I've tried different method but without success.

Hope that I explain myself well.
Kind Regards to whom will help me.

3 Replies

Use the [[]] notation to grab a part of an expression:

Yourvariable[[All,2]]

Or

Yourvariable[[All,2,1]]
POSTED BY: Sander Huisman

Something like:

Select[yourdata, First/*StringMatchQ[___~~”a”~~___~~”60s”~~__]]

Should work… I don’t have my laptop now with me…

POSTED BY: Sander Huisman

THIS WORK PERFECTLY! THANKS A LOT.

I would like also to take from this new list, the first parameter for each data set

this one for example

{"01-a-mas-480s.dat", {1.24}} {"02-a-mas-480s.dat", {0.77}} ect ect

how can I do it?

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract