Info

This question is closed. Reopen it to edit or answer.

Concatinate datasets with the same first x letters in a workspace

1 view (last 30 days)
I have several thousand datasets in my workspace and I want to concatenate (maybe using vertcat?) those with variable names that have the same first x letters together. Any ideas on how to do this?
  1 Comment
Jasmine
Jasmine on 24 Jul 2014
How is the data saved? I'm assuming as a string. You could do something like this for each dataset if count is how many different dataset you have:
cnt = 1
for j=1:count
for i=1:5
if i==1
a = dataset(i)
else
if dataset(i) == a
if i == 5
finaldataset(cnt,:) = dataset
end
end
end
end
end
I think this will simply list all those datasets which the first 5 letters are the same (completely untested literally just written it here). If you need to have, say, all those which start with 5 As in a different variable than all those that start with 5 Bs, you'll need to add this in somehow. At the moment the best method I can think of is a switch-case statement for each letter of the alphabet. But this would be time consuming so maybe someone else can suggest a better method.

Answers (0)

Community Treasure Hunt

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

Start Hunting!