how do i plot certain columns and rows of a matrix

조회 수: 3 (최근 30일)
Praneeth K V
Praneeth K V 2017년 4월 22일
댓글: Image Analyst 2017년 4월 23일
i have a matrix of 40*7 and I need to plot columns of only 3rd and 6th. How do I do it?
  댓글 수: 1
Praneeth K V
Praneeth K V 2017년 4월 22일
Sorry, I had put my question wrong. I have to plot a line using x and y coordinates of 2 points which are in different columns, how do I do that

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

답변 (2개)

KSSV
KSSV 2017년 4월 22일
A = rand(40,7) ;
figure
hold on
plot(A(:,6),'r')
plot(A(:,7),'b')
legend('6th column', '7th column');
  댓글 수: 1
Image Analyst
Image Analyst 2017년 4월 22일
Replace 7 with 3 to get "only 3rd and 6th" columns.

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


Image Analyst
Image Analyst 2017년 4월 22일
Try this
line([x1, x2], [y1, y2], 'Color', 'b', 'LineWidth', 2);
where the x1 and y1 come from one column, and the x2 and y2 come from the second column. If that doesn't work, then post your data sand indicate which elements of the array you want a line drawn between.
  댓글 수: 2
Praneeth K V
Praneeth K V 2017년 4월 23일
편집: Praneeth K V 2017년 4월 23일
line([x0(Elem(i,3)),x0(Elem(i,6))], [y0(Elem(i,3)),y0(Elem(i,6))],'Color','b','LineWidth','2'); this is the code i wrote.
ps: Im using loop to create multiple lines and 'i' is the variable parameter
x0 is column matrix and y0 is other column matrix. to create a line im selecting points from x0 and y0 with reference of Elem matrix but this shows error of "Error using line While setting property 'LineWidth' of class 'Line': Value not a numeric scalar"
Image Analyst
Image Analyst 2017년 4월 23일
Did you see where it said the LineWidth was not a scalar and how you were passing it a string? I said to use 'LineWidth', 2 NOT 'LineWidth', '2'. Do not put the 2 in single quotes.

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

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by