Tag: vector

54 votes
4 answers
2.4K views
Is there an R function for finding the index of an element in a vector?

In R, I have an element x and a vector v. I want to find the first index of an element in v that is equal to x

avatar
Basil
0 1 0 9
asked 07 September, 2021
57 votes
20 answers
1.6K views
Counting the number of elements with the values of x in a vector

I have a vector of numbers: numbers <- c(4,23,4,23,5,43,54,56,657,67,67,435, 453,435,324,34,456,5

avatar
Rudy
0 1 0 9
asked 07 September, 2021
59 votes
7 answers
2.1K views
Test if a vector contains a given element

How to check if a vector contains a given value?

avatar
Jesenia
0 1 0 9
asked 07 September, 2021
66 votes
3 answers
769 views
Octave/Matlab: Adding new elements to a vector

Having a vector x and I have to add an element (newElem) . Is there any difference between - x(end+1) = new

avatar
Kurtis
0 1 0 9
asked 07 September, 2021
63 votes
2 answers
1.6K views
Octave / Matlab: Extend a vector making it repeat itself?

Is there a way to extend a vector by making it repeat itself? >v = [1 2]; >v10 = v x 5; %x represents s

avatar
Georgie
0 1 0 9
asked 07 September, 2021
55 votes
11 answers
846 views
How can I apply a function to every row/column of a matrix in MATLAB?

You can apply a function to every item in a vector by saying, for example, v + 1, or you can use the function

avatar
Adolfo
0 1 0 9
asked 07 September, 2021