Draw mesh for 2-d array

3 ビュー (過去 30 日間)
Babu Poomalai
Babu Poomalai 2011 年 3 月 21 日
コメント済み: Walter Roberson 2024 年 9 月 3 日
I have 2-d array as input...size is (64*64)..I want to represent it as mesh...I tried with mesh functions but no success...Please help me
  1 件のコメント
Matt Tearle
Matt Tearle 2011 年 3 月 21 日
Can you give some details about what isn't working? This works for me:
z = cumsum(rand(64)); % makes a 64-my-64 matrix
mesh(z) % makes a mesh plot

サインインしてコメントする。

回答 (1 件)

Anshuman
Anshuman 2024 年 9 月 2 日
You can try something like this to represent your array as mesh:
% Example 2D data array (64x64)
data = rand(64, 64); % Replace this with your actual data
% Create a grid of x and y coordinates
[x, y] = meshgrid(1:size(data, 2), 1:size(data, 1));
% Plot the mesh
figure;
mesh(x, y, data);
% Add labels and title for clarity
xlabel('X-axis');
ylabel('Y-axis');
zlabel('Z-axis');
title('Mesh Plot of 2D Data Array');
Hope it helps!
  1 件のコメント
Walter Roberson
Walter Roberson 2024 年 9 月 3 日
In the case where your x and y are 1 to the number of points, you do not need to construct the x and y explicitly.
data = rand(64, 64);
mesh(data);
% Add labels and title for clarity
xlabel('X-axis');
ylabel('Y-axis');
zlabel('Z-axis');
title('Mesh Plot of 2D Data Array');

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by