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
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
madhan ravi 2018년 12월 4일
편집: madhan ravi 2018년 12월 4일

0 개 추천

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
Nikhil Gakkhar 2018년 12월 4일
Hello Ravi,
When I am usign this code, there are some issue:
a) The values of Y are in matrix array, so it is not taking the values
and so
b) the graph is with no points
If i had Y =[12 24 36 48 60 72 84 96 108], then it is working fine.
But I am getting y as a result of some equation.
So i got value of Y as one of column in matrix.
RESULT(n,:) = (Y)
Can you help me, how to retreive that column from matrix which i have got?
madhan ravi
madhan ravi 2018년 12월 4일
if Y is a matrix then Y(:,1) retrieves first column likewise for the rest
Nikhil Gakkhar
Nikhil Gakkhar 2018년 12월 4일
Thanks.
I got it now.
Just in case, Y(:,1) i want to omit first two row of column so that X and Y would be of same size
how to do that?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

제품

태그

질문:

2018년 12월 4일

댓글:

2018년 12월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by