Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Concatinate datasets with the same first x letters in a workspace

1 回表示 (過去 30 日間)
Daniel Gardner
Daniel Gardner 2014 年 7 月 24 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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 件のコメント
Jasmine
Jasmine 2014 年 7 月 24 日
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.

回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by