Matlab question: How to pick specific value from column vector

In summary, to pick a specific value from a column vector in Matlab, you can use the indexing operator ([]). You can also pick multiple values by using the colon operator (:) within the indexing operator ([]). To pick a specific value based on a condition, you can use logical indexing. The "end" keyword can be used to pick the first or last value from a column vector. And to pick a value from a specific row and column in a matrix, you can use two indexing operators ([][]) in Matlab.
  • #1
bmed90
99
0
Good afternoon,

I have created a column vector with many values however I want to know a specific value found in that vector. Specifically I want to know the 99th value of my column vector. Is there a command I can enter into mat lab that will give me the value I seek without having to manually count through the outputted data in the output window? Thanks!
 
Physics news on Phys.org
  • #2
I figured it out, its actually quite simple say the vector is names time. Just type in

time(99)
 

1. How do I pick a specific value from a column vector in Matlab?

To pick a specific value from a column vector in Matlab, you can use the indexing operator ([]). For example, if your column vector is named "vector" and you want to pick the value in the third row, you can use "vector(3)". This will return the value at the third row in the vector.

2. Can I pick multiple values from a column vector in Matlab?

Yes, you can pick multiple values from a column vector in Matlab by using the colon operator (:) within the indexing operator ([]). For example, if you want to pick the values from the second to fifth row in the vector, you can use "vector(2:5)". This will return a sub-vector with the values from the second to fifth row.

3. What if I want to pick a specific value from a column vector based on a condition?

You can use logical indexing in Matlab to pick a specific value from a column vector based on a condition. For example, if you want to pick the value in the vector that is greater than 10, you can use "vector(vector>10)". This will return the value(s) that meet the condition.

4. Is there a way to pick the first or last value from a column vector in Matlab?

Yes, you can use the "end" keyword in Matlab to pick the first or last value from a column vector. For example, if you want to pick the last value in the vector, you can use "vector(end)". This will return the last value in the vector regardless of its length.

5. Can I pick a value from a specific row and column in a matrix using Matlab?

Yes, you can use two indexing operators ([][]) to pick a specific value from a matrix in Matlab. For example, if you have a matrix named "matrix" and you want to pick the value in the third row and second column, you can use "matrix(3,2)". This will return the value at the intersection of the third row and second column in the matrix.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
Replies
1
Views
599
  • Engineering and Comp Sci Homework Help
Replies
7
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
Back
Top