How do I plot multiple vectors in a graph

조회 수: 3 (최근 30일)
Luiz Felipe
Luiz Felipe 2023년 1월 15일
편집: Image Analyst 2023년 1월 15일
I have two vectors and I need them to plot together on the same graph.
Example:
A = [1,2,3,4,5,6]
B = [1,2,3,4,5,6]
Assuming that the X of the graph is the vector A, I need all the values of A to appear, in relation to a point of the vector B, which would be the Y, so the (x,y) would be:
(1,1),(2,1),(3,1),.....
So successively until vector B runs out.
(1.6), (2.6), (3.6), ....

답변 (1개)

Voss
Voss 2023년 1월 15일
편집: Voss 2023년 1월 15일
Like this?
A = 1:6;
B = 1:6;
[Ap,Bp] = ndgrid(A,B);
plot(Ap,Bp)
  댓글 수: 2
Luiz Felipe
Luiz Felipe 2023년 1월 15일
EXACTLY, but how can I place the lines vertically with the same references?
Image Analyst
Image Analyst 2023년 1월 15일
편집: Image Analyst 2023년 1월 15일
@Luiz Felipe you can place vertical lines at arbitrary locations with xline
You can also use
grid on
if you want them along tick marks.

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

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by