Clear Filters
Clear Filters

How to plot hexagonal boundary graph

2 views (last 30 days)
Hello, I am currently studying on plotting the graph. And I am trying to plot hexagonal graph shown in the attachment.
However when I extracted the results into txt file and put in the matlab, the results was shown like following attachment
file = readtable('wignertxt_111_5e20.xlsx');
x=table2array(file(:,1));
y=table2array(file(:,2));
z=table2array(file(:,3));
kA = reshape(x,379,7);
kB = reshape(y,379,7);
T = reshape(z,379,7);
%[X,Y,Z] = meshgrid(kA,kB,T);
%shading interp;
surf(kA, kB, T)
view(2)
the below Excel file is the txt file from the 1st picture attachment.
Can anyone please help me with this issues?
It would be a great help.
Thank you for reading.

Accepted Answer

Kyoung Moon Lee
Kyoung Moon Lee on 18 Jan 2024
Edited: Kyoung Moon Lee on 18 Jan 2024
In order to create a contour graph in matlab, we need to convert to nXn data instead of 1xn.
clc; clear; close all;
% option control
op.resolution = 1000;
% read data
data = readmatrix('wignertxt_111_5e20.xlsx');
x = data(:,1);
y = data(:,2);
z = data(:,3);
% make grid
x1 = linspace(min(x),max(x),op.resolution);
y1 = linspace(min(y),max(y),op.resolution);
% interpolation
[x2,y2] = meshgrid(x1,y1);
z2 = griddata(x,y,z,x2,y2);
% figure
contourf(x2,y2,z2,'LineStyle','none')
colorbar

More Answers (0)

Community Treasure Hunt

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

Start Hunting!