Scatter point with matrix blocks

2 次查看(过去 30 天)
Hi,
Make a scatter diagram like the below attached one? I've got period on my x axis and wave height on the y axis, but would like to group them and can't figure that out. Appreaciate your help.
figure(1)
scatter(T_p,H_s)
figure(2)
scatter(z,H_s)
  2 个评论
darova
darova 2021-3-4
How do you want to group them? Maybe by high water level z(m)?
Hozan Sulaiman
Hozan Sulaiman 2021-3-12
Just as the figure I've uploaded, within an interval of height and water level, how many points I've got.
Thank you.

请先登录,再进行评论。

回答(1 个)

Mathieu NOE
Mathieu NOE 2021-3-12
hello
this coud do the trick
example below :
%% generate a test matrix
A = round(10*rand(20, 20));
%% visualize the matrix
matvisual(A, 'annotation')
grid off
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Matrix Visualization with MATLAB Implementation %
% %
% Author: Ph.D. Eng. Hristo Zhivomirov 12/02/18 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function matvisual(A, varargin)
% function: matvisual(A, varargin)
% A - m-by-n matrix to be visualized with up to 3 pages
% varargin - type 'annotation' in the place of varargin if one want to
% annotate the matrix plot (x-label, y-label, etc.)
% check the input
if ~isreal(A) | isempty(A) | ischar(A) | ndims(A) > 3
errordlg('The data array is not suitable for visualization!', ...
'Error!', 'modal')
return
end
% determine the matrix size
[M, N, P] = size(A);
% loop through the matrix pages
for p = 1:P
% prepare page-by-page visualization
if P > 1, subplot(1, P, p), end
% visualize the matrix
himg = imagesc(A(:, :, p));
grid on
% annotation
if strcmp(varargin, 'annotation')
% x-label, y-label, x-ticks, y-ticks, title
set(gca, 'FontName', 'Arial', 'FontSize', 12)
xlabel('Column number')
ylabel('Row number')
if P > 1, title(['Matrix page ' num2str(p)]), end
if M <= 50, set(gca, 'YTick', 1:M), end
if N <= 50, set(gca, 'XTick', 1:N), end
end
% values labeling
for m = 1:M
for n = 1:N
text(n, m, num2str(A(m, n, p), 3), ...
'FontName', 'Arial', ...
'FontSize', round(6 + 50./sqrt(M.*N)), ...
'HorizontalAlignment', 'center', ...
'Rotation', 45)
end
end
% % set the datatip UpdateFcn
% cursorMode = datacursormode(gcf);
% set(cursorMode, 'UpdateFcn', {@datatiptxt, himg})
end
end
function text_to_display = datatiptxt(hDatatip, himg)
% determine the current datatip position
pos = get(hDatatip, 'Position');
% form the datatip label
text_to_display = {['Row: ' num2str(pos(2))], ...
['Column: ' num2str(pos(1))], ...
['Value: ' num2str(himg.CData(pos(2), pos(1)))]};
end
  2 个评论
Hozan Sulaiman
Hozan Sulaiman 2021-3-15
Hi, it doesn't, this is basically what I've written :
Mdata = scatter_function("C:\m\P2\Mdata.xlsx", "1210467 - Metocean study for th", [11, 175330]);
%U_10= Mdata(:,2)
%Wind_D=Mdata(:,4)
H_s=Mdata(:,6)
T_p=Mdata(:,8)
%Wave_D=Mdata(:,10)
z=Mdata(:,12)
%Uc_x=Mdata(:,14)
%Uc_y=Mdata(:,16)
figure(1)
scatter(T_p,H_s)
figure(2)
scatter(z,H_s)
You've used a matrix, I'm not sure I know how to use it for the 2 different vectors I've got.
So these 2 figures are what I get, and I want to split those into intervals as you've shown.
Thank you for your help
Mathieu NOE
Mathieu NOE 2021-3-15
hello
IMO you have to plot a Bivariate histogram plot
then either you stick to the graphical 3D rendering (example of the histogram2 function )
, or you can use my previous suggestion
hope it helps

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Axis Labels 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by