How to plot from array
古いコメントを表示
Hello
I am trying to plot a XY 2D graph but stuck in geeting array values. I have defined my x=10:1:20
and y values are the result obtained from the array. The Y values (lets say) are obtained from the following
n=1
for i=1:10
RESULT(n,:) = (Y)
end
I am getting Y values as [12 24 36 48 60 72 84 96 108]
using these as Y points and X as 10:1:20, i want to plot XY graph.
Kindly help.
Thanks
1 件のコメント
Stephen23
2018 年 12 月 4 日
You have nine Y values and eleven X values: how do you expect to plot them together?
>> Y = [12 24 36 48 60 72 84 96 108]
Y =
12 24 36 48 60 72 84 96 108
>> X = 10:20
X =
10 11 12 13 14 15 16 17 18 19 20
^^^^^^^^ What Y values ?
回答 (1 件)
madhan ravi
2018 年 12 月 4 日
編集済み: madhan ravi
2018 年 12 月 4 日
X=10:20;
Y = [12 24 36 48 60 72 84 96 108];
plot(X(1:numel(Y)),Y)
Alternatively
Y = [12 24 36 48 60 72 84 96 108];
X=linspace(10,20,numel(Y)); % to match the sizes of X and Y
plot(X,Y)
3 件のコメント
Nikhil Gakkhar
2018 年 12 月 4 日
madhan ravi
2018 年 12 月 4 日
if Y is a matrix then Y(:,1) retrieves first column likewise for the rest
Nikhil Gakkhar
2018 年 12 月 4 日
カテゴリ
ヘルプ センター および File Exchange で Data Distribution Plots についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!