Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Concatinate datasets with the same first x letters in a workspace

1 Ansicht (letzte 30 Tage)
Daniel Gardner
Daniel Gardner am 24 Jul. 2014
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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 Kommentar
Jasmine
Jasmine am 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.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by