how to plot matrix in matlab?

4 ビュー (過去 30 日間)
AMAN KUMAR
AMAN KUMAR 2020 年 5 月 22 日
コメント済み: Walter Roberson 2025 年 5 月 28 日
I have 2d matrix for different resistivity layers and sounding (Depicted in x axis)
  3 件のコメント
Walter Roberson
Walter Roberson 2020 年 5 月 22 日
In particular the 'stacked' option of 'bar'
AMAN KUMAR
AMAN KUMAR 2020 年 5 月 26 日
I have used heatplot here over stacked bar "using imagesc(), colorbar" .
just I have to make a 2d matrix but for all 300 depth points, but its a lengthy method
yes, bar() stacked method is useful and easier can anyone share with me the code for bar() "stack"

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

回答 (1 件)

Aditya
Aditya 2025 年 5 月 28 日
Hi Aman,
To plot a 2D matrix in MATLAB, you can use the following functions:
  • imagesc(): Used for visualizing matrix values as a color-scaled image. Best for displaying resistivity layers.
imagesc(matrix);
colorbar;
title('Heatmap of Matrix');
  • bar() with 'stacked': Used to represent matrix columns in a stacked bar format. Ideal for layer comparisons.
bar(matrix, 'stacked');
title('Stacked Bar Chart');
  • surf(): Used for creating 3D surface plots of matrix values.
surf(matrix);
shading interp;
title('3D Surface Plot');
If you want to read more about these functions, refer to the below MATLAB documentation link:
I hope this helps!
  1 件のコメント
Walter Roberson
Walter Roberson 2025 年 5 月 28 日
A few notes:
imagesc() assumes that the values are equally spaced, and there is no way of changing that.
The XData and YData options of imagesc() allow you to select the X or Y coordinates that the image will be painted into; but be careful because the coordinates you pass are treated as the centers of the outermost pixels, not as the edges of the outermost pixels.
surf() is able to handle irregularly spaced data, including data coordinates that curve.
surf() takes the input coordinates as being the coordinates of vertices, and interpolates between four vertices to get the face color displayed. Because of this, for an N x M array of input data, surf() will only draw (N-1) x (M-1) faces and the faces will not directly represent the input data.

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

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by