plotting a 2-colum 2d array

2 ビュー (過去 30 日間)
William Lancelot
William Lancelot 2021 年 10 月 18 日
コメント済み: William Lancelot 2021 年 10 月 18 日
I have a 2-d array that looks like this:
a = [1, 2; 5, 6; 10, 11; 1000, 12];
which should traslate into this
1 2
5 6
10 11
1000 12
I want to consider the first column the x-axis and the second the y- axis and plot, so I did this
plot(UIAxes, a.(2),a.(1));
but I receive the error below:
Argument to dynamic structure reference must evaluate to a valid field name.
any help please - thanks

採用された回答

Walter Roberson
Walter Roberson 2021 年 10 月 18 日
That syntax of using . and then a number inside (), only works for table() objects.
UIAxes = gca;
A = [1, 2; 5, 6; 10, 11; 1000, 12];
a = array2table(A);
plot(UIAxes, a.(2),a.(1));
  1 件のコメント
William Lancelot
William Lancelot 2021 年 10 月 18 日
thank you

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

その他の回答 (1 件)

David Hill
David Hill 2021 年 10 月 18 日
plot(a(:,1),a(:,2));
  1 件のコメント
William Lancelot
William Lancelot 2021 年 10 月 18 日
thank you

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

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by