Scatter matrix of probability of occurrence
3 views (last 30 days)
Vidura Vishvanath on 13 Apr 2022
I have a set of data corresponding to two Variables Hs and Tp and I need to generate a scatter matrix with probablities of occurence as given in the figure below.
I was able to split Hs values into intervals using 'discretize' and seperate corrosponding Tp values using,
%% SCATTER PLOT
clc; clear all; close all;
Hs = table2array(readtable('Wave.xlsx','Range','A2:A5849'));
Tp = table2array(readtable('Wave.xlsx','Range','B2:B5849'));
edges = 0:0.5:4;
limit = length(edges)-1;
binindices = discretize(Hs,edges);
splitHs = arrayfun(@(bin) Hs(binindices == bin), 1:limit, 'UniformOutput', false);
splitTp = arrayfun(@(bin) Tp(binindices == bin), 1:limit, 'UniformOutput', false);
However im having a hard time figuring out a way to build the matrix. any help would be appreciated.
Data is attached. Thank you!
Simon Chan on 13 Apr 2022
You may use function hiscounts2
rawdata = readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/963270/Wave%20data_Galle_NARA.xlsx');
Hs_edges = 0:0.5:6;
Tp_edges = 4:1:22;
[N,Xedges,Yedges,binX,binY] = histcounts2(rawdata(:,2),rawdata(:,1),Tp_edges,Hs_edges,'Normalization','probability');