Extracting text frequency to compare large datasets
显示 更早的评论
Please can you help me to extract the frequency at which each port receives each gear type. The data set is huge, so I need MATLAB to read through and give results for the frequency of Appledoor "Pots and Traps", for example, so that can then be compared with Appledoor "Demersal trawl/seine" or Arbroath "Pots and traps" if needed. They are currently in two columns in an Excel workbook.
Port of Landing Gear Category
Appledore Pots and traps
Appledore Pots and traps
Arbroath Demersal trawl/seine
Arbroath Pots and traps
Arbroath Pots and traps
Arbroath Demersal trawl/seine
Ardglass Demersal trawl/seine
Ardglass Demersal trawl/seine
Ardglass Demersal trawl/seine
Ardglass Pots and traps
Ardglass Pots and traps
Aberdaran Pots and traps
Aberdaran Pots and traps
Aberdeen Pots and traps
1 个评论
Image Analyst
2019-6-14
Make it easy for people to help by attaching an Excel workbook.
回答(1 个)
Image Analyst
2019-6-14
Try histogram2():
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format short g;
format compact;
fontSize = 20;
ca = {...
'Appledore' 'Pots and traps'; ...
'Appledore' 'Pots and traps'; ...
'Arbroath' 'Demersal trawl/seine'; ...
'Arbroath' 'Pots and traps'; ...
'Arbroath' 'Pots and traps'; ...
'Arbroath' 'Demersal trawl/seine'; ...
'Ardglass' 'Demersal trawl/seine'; ...
'Ardglass' 'Demersal trawl/seine'; ...
'Ardglass' 'Demersal trawl/seine'; ...
'Ardglass' 'Pots and traps'; ...
'Ardglass' 'Pots and traps'; ...
'Aberdaran' 'Pots and traps'; ...
'Aberdaran' 'Pots and traps'; ...
'Aberdeen' 'Pots and traps'}
ports = ca(:, 1)
gear = ca(:, 2)
[portGroups, portNames] = findgroups(ports)
[gearGroups, gearNames] = findgroups(gear)
h = histogram2(portGroups, gearGroups)
xticks(unique(portGroups));
yticks(unique(gearGroups));
zticks(1:max(h.BinCounts(:)))
xticklabels(portNames);
yticklabels(gearNames);
xlabel('Port', 'FontSize', fontSize)
ylabel('Gear', 'FontSize', fontSize);

类别
在 帮助中心 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!