Make a plot using value from a certain line of matrix

1 回表示 (過去 30 日間)
Huichen Zhang
Huichen Zhang 2016 年 10 月 8 日
コメント済み: dpb 2016 年 10 月 8 日
Suppose I have a matrix of dimension 10x10. Now I want to use the value along the column 5 as Y axis, and use the index of rows to represent x increment, how can I make a plot like that in Matlab? And at the same time, when I do the contour plot of a matrix, is it a way to indicate the highest and lowest value in the contour plot?

採用された回答

Massimo Zanetti
Massimo Zanetti 2016 年 10 月 8 日
編集済み: Massimo Zanetti 2016 年 10 月 8 日
Herre it is:
%define a 10x10 matrix
A=rand(10,10);
%plot its 5th column with index as x axis
plot(A(5,:));
%detect min and max
[minv,imin]=min(A(5,:));
[maxv,imax]=max(A(5,:));
%add them to plot
hold on;
plot(imin,minv,'*',imax,maxv,'d');
legend('line','min','max')
hold off;
  3 件のコメント
Massimo Zanetti
Massimo Zanetti 2016 年 10 月 8 日
To plot the contour
[C,h] = contour(A);
clabel(C,h);
dpb
dpb 2016 年 10 月 8 日
plot(A(5,:));
NB: that this is 5 th row, not column...it's row 5, all columns; the indices are reversed regarding the question posed.

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

その他の回答 (1 件)

dpb
dpb 2016 年 10 月 8 日
  1. plot(Y(:,5))
  2. clabel(C,h,[v(1) v(end)])

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by