if it further helps my explanation, the x position should be constant, where as the y values should take on every value in the row I extract. The normal plot function is obviously giving me issues because the vertical line plot will not be single-valued for a given x-value. The visualization will just serve as a good check that I am extracting an array of 'y-values' on the plot that are in a region I want to further analyze.
How to plot a vector (array) as a vertical line?
조회 수: 6 (최근 30일)
이전 댓글 표시
Say I have, from my data, a vector x, where x is a 1 x n row vector. How do I plot this as a vertical column vector on an already existing plot? I want to compare data in a specific region of a contour plot. I need to know which region of the contour plot I am extracting my data so that I can be absolutely sure I am comparing the correct regions of data, hence why I want to graph vertical lines on the plot.
So, for example, if:
clear all;
close all;
clc;
a = [1,2,3,3,1;2,3,4,4,2;3,7,7,7,3;4,11,19,23,4;5,70,4,30,5];
%Get size of rows of above matrix
vec = 1:size(a,1);
%Pick out all columns of matrix in row 3
q = a(2,:);
%Plot Contour
contour(a)
hold on
plot(vec(2),q)
hold off
I intend to use the array I called 'q' for further analysis in my real program, but I want to make sure I am extracting the correct vector that I want to analyse. For example, in my example plot here, I want to investigate the vector that is giving me the sharp points at the bottom tip of the series of symmetric cheverons that one can see in the plot of this program, which appear to be at the graphical mark of x = 2 on the plot. Not only do I want to extract that vector, but I want to have a visual cue that I am indeed taking the correct vector from my contour plot, which I can currently only tell by visualization, hence my desire to plot a vertical line to indicate that I have extracted the equivalent of all of the values in the matrix that are expressed along that vertical line. So, I want to extract a entire 'y-array' for a given value of 'x' on my contour plot, and visually plot the vertical line I extracted, to visually see where that extracted array is located in the contour plot. Hopefully I didn't write this in a confusing manner.
답변 (1개)
BM
2018년 2월 27일
편집: BM
2018년 2월 27일
댓글 수: 4
Stephen23
2018년 2월 27일
편집: Stephen23
2018년 2월 27일
@BMor: you called contour with one input argument, which means that the X and Y axes are simply the indices of those dimensions of the input matrix. This means the Y range is
[1,size(a,1)]
If you want the entire vector of all Y values that have been plotted then:
1:size(a,1)
You can easily plot these against the vector q, if that is what you are aiming for.
참고 항목
카테고리
Help Center 및 File Exchange에서 Contour Plots에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!