![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1593816/image.png)
How to plot hexagonal boundary graph
4 次查看(过去 30 天)
显示 更早的评论
Hello, I am currently studying on plotting the graph. And I am trying to plot hexagonal graph shown in the attachment.![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1593741/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1593741/image.png)
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)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1593746/image.png)
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.
0 个评论
采纳的回答
Kyoung Moon Lee
2024-1-18
编辑:Kyoung Moon Lee
2024-1-18
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1593816/image.png)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Directed Graphs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!