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