Combine 2 datasets and include the duplicates

6 ビュー (過去 30 日間)
Sarah Aldridge
Sarah Aldridge 2021 年 3 月 17 日
回答済み: Seth Furman 2021 年 3 月 18 日
I have two datasets, the first is a list of postcodes gathered from a survey, the second is a matrix that cross-references all postcodes with the areas they are in. I want to generate a column listing the areas that the survey postcodes represents.
The part I am having trouble with is that in some cases, one postcode can correspod to mutiple areas, in these situations I want to include both areas in the new column.
I've tried joining the tables, but the standard Join command seems to have issues with there being duplicate values

回答 (2 件)

ANKUR KUMAR
ANKUR KUMAR 2021 年 3 月 17 日
clc
clear
postcodes=randi(20,50,1);
areas=randi(10,50,5);
area_unique=unique(areas);
for ii=1:length(area_unique)
[xx,yy]= find(areas==area_unique(ii));
postcode_ref{ii}=unique(xx)';
end
If it helps you, then it's good. Otherwise, if you can provide the datset (or sufficient variables in a mat file), it owuld help us to help you.

Seth Furman
Seth Furman 2021 年 3 月 18 日

カテゴリ

Help Center および File ExchangeExplore and Edit Images with Image Viewer App についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by