Matlab - Tips and Tricks on Manipulating 1-D Arrays (Vectors)
14 Jan 2008 Quan Quach 85 comments 19,927 views
Introduction
1-D Arrays (also known as vectors) are commonly used within Matlab, so it is a good idea to understand how they work and how to bend them to your will. This is a quick tutorial on some simple tricks that you may or may not know about vectors.
Creating Vectors
-
How to create a row vector that increments by 1. For example, let’s create a row vector that goes from 1 to 10, with increments of 1.
myVector = [1 2 3 4 5 6 7 8 9 10]; %the hard way myVector = 1:10 %the easy way
-
How to transform a row vector to a column vector, and vice versa.
myVector = 1:10; %creates a row vector myVector = myVector' %this is the complex conjugate transpose myVector = myVector.' %is the non-conjugate transpose
-
How to create a column vector that increments by 1. For example, let’s create a column vector that goes from 1 to 10, with increments of 1.
myVector = [1; 2; 3; 4; 5; 6; 7; 8; 9; 10]; %the hard way myVector = [1:10].' %the easy way
-
How to create a vector that increments by a specific value. Let’s create a vector that goes from 1 to 19, and increments by 2. Note that the increment value is not limited to integers.
myVector = 1:2:19
-
How to create a vector that decrements by a specific value. Let’s create a vector that goes from 10 to 1, and decrements by 1
myVector = 10:-1:1
-
How to create a vector with equally spaced points. Let’s create a vector that goes from 0 to 100 with 21 equally spaced points.
%first argument is the start value of the vector %second argument is the end value of the vector %third argument is the number of points within the vector myVector = linspace(0,100,21)
-
How to create a vector of zeros. For example, let’s create a vector of 10 zeros.
%first argument is the number of rows %second argument is the number of columns rowZeros = zeros(1,10)
Note: Incidentally, this is a great way to preallocate a vector. Preallocating a vector is most useful when FOR loops are involved. Preallocating a vector is preferred over resizing a vector repeatedly as it reduces the processing time.
-
How to create a vector of ones. For example, let’s create a vector of 10 ones.
%first argument is the number of rows %second argument is the number of columns rowOnes = ones(1,10)
Note: This is yet another way to preallocate a vector.
-
How to append a vector. For example, lets add 11 to the end of the vector
myVector = 1:10; myVector = [myVector 11] %we can also add 11 to the beginning of the vector myVector = [11 myVector];
Note: This method of appending vectors should not be used within large FOR loops. When resizing arrays, memory must be reallocated with a larger size. If this is done repeatedly, there is a speed penalty.
-
How to append two vectors together.
myVector1 = 1:5; myVector2 = 6:10; myVectorAppend = [myVector1 myVector2] %myVectorAppend = cat(2,myVector1,myVector2) does the same thing
Note: Same warning as above.
-
How to remove a particular element from a vector. Lets say we want to remove the 4th entry.
myVector = 1:10; myVector(4) = []
-
How to replace a particular element with a different element within a vector. Lets say we want to replace the 4th entry with the value of 100.
myVector = 1:10; myVector(4) = 100
-
How to remove the last element from a vector.
myVector = 1:10; myVector(end) = []
-
How to remove the last 5 elements.
myVector = 1:10; myVector(end-4:end) = []
-
How to keep the last 5 elements (or equivalently, remove the first five elements).
myVector = 1:10; myVector = myVector(end-4:end) %the following command does the same thing myVector(1:5) =[];
-
How to remove a series of elements. For example, let’s remove entries 3 through 6:
myVector = 1:10; myVector(3:6) = []
-
How to keep a series of elements. For example, let’s keep entries 3 through 6:
myVector = 1:10; myVector = myVector(3:6)
-
How to remove a group of specific elements. For example, lets remove entries 2,5, and 7:
myVector = 1:10; myVector([2,5,7]) = []
-
How to keep a group of specific elements. For example, lets keep entries 2,5, and 7:
myVector = 1:10; myVector = myVector([2,5,7])
-
How to get the number of elements within a vector. Useful when creating a for loop to run through a vector.
myVector = 1:10; numElements = length(myVector) %the following command does the same thing numElements = numel(myVector)
-
How to remove all zeros from a vector.
myVector = [0 0 0 1 2 3 0 0 4 5 1 2 0 0]; %index contains the indices elements within myVector which are non-zero index = find(myVector); myVector = myVector(index) %removes all the zeros within the vector
Alternatively, logical indexing can be used (and is more efficient)
myVector(myVector == 0) = [];
-
How to remove a particular value from a vector. For example, how to remove any occurence of 6 within a vector
myVector = [6 6 0 1 2 3 0 0 6 6 1 2 0 0]; %index contains the indices of elements within myVector which are equal to 6 index = find(myVector == 6 ); myVector(index) = []
Alternatively, logical indexing can be used (and is more efficient)
myVector(myVector == 6) = [];
-
How to remove the first two occurences of 6 within a vector
myVector = [6 6 0 1 2 3 0 0 6 6 1 2 0 0]; index = find(myVector == 6,2); myVector(index) = []
-
How to remove all elements greater than 5 from a vector.
myVector = [10 0 0 1 12 3 0 0 4 5 1 12 0 0]; %index contains indices of elements within myVector which are greater than 5 index = find(myVector > 5); myVector(index) = []
Alternatively, logical indexing can be used (and is more efficient)
myVector(myVector > 5) = [];
-
Similarly, how to remove all elements less than 5 from a vector.
myVector = [10 0 0 1 12 3 0 0 4 5 1 12 0 0]; %index contains the indices of elements within myVector which are less than 5 index = find(myVector < 5); myVector(index) = []
Alternatively, logical indexing can be used (and is more efficient)
myVector(myVector < 5) = [];
-
How to reverse a vector.
myVector = 1:10; myVector = myVector(end:-1:1)
-
How to sort a vector.
myVector = [10 0 0 1 12 3 0 0 4 5 1 12 0 0]; myVectorAscend = sort(myVector) %sort ascending myVectorDescend = sort(myVector,'descend') %sort descending
-
How to shift the elements one spot to the right.
myVector = 1:10; myVector = myVector([end 1:end-1])
-
How to shift the elements one spot to the left.
myVector = 1:10; myVector2 = myVector([2:end 1])
-
How to get the maximum and minimum value of a vector
myVector = [10 0 0 1 12 3 0 0 4 5 1 12 0 0]; maxValue = max(myVector); minValue = min(myVector);
-
How to add up all the elements within a vector.
myVector = 1:10; total = sum(myVector);
-
How to get the product of all the elements within a vector.
myVector = 1:10; total = prod(myVector);
-
How to get the average, standard deviation, and variance of a vector.
myVector = 1:10; averageArray = mean(myVector) stdArray = std(myVector) varArray = var(myVector)
Note: Dan Kominsky pointed out that is a subtle but important difference here. When you are working with real numbers the difference is irrelevant, but when you are dealing with complex numbers, the meaning is entirely different! Thanks for the correction, Dan.
Adding, Removing, and Replacing Elements within a Vector
Sorting and Shifting Vectors
Other useful commands:
Got any tricks up your sleeve?
There are a ton of Matlab tricks that were not covered in this tutorial. Do you know of any super useful trick? If you have any of your own tips and tricks up your sleeve, please share at least one!
85 Responses to “Matlab - Tips and Tricks on Manipulating 1-D Arrays (Vectors)”
Leave a Reply
Include MATLAB code in your comment by doing the following:
<pre lang="MATLAB">
%insert code here
</pre>


I’m sorry to tell you that you made one of the classic blunders of matlab programming. The transpose of a vector is NOT myVector’ ! It is myVector.’ When you are working with real numbers the difference is irrelevant, but the myVector’ is the complex conjugate of the transpose! And believe me it is a royal pain to debug that mistake, since it is a coding error that is very hard to see. Hope this helps.
Dan
Dan K:
Thanks for the correction. It is a subtle, but important point!! I have edited the post to reflect your comment.
Thanks,
Quan
Actually, Quan, there is one other major area in which your code is inefficient (although functionally correct). It is generally significantly faster to use logical indexing rather than the find command. For example in item number 24 you use:
index = find(myVector > 5);
myVector(index) = []
Whereas a faster implementaiton (and, I think more clear) is:
myVector(myVector >5)=[];
HTH,
Dan
Thanks Again Dan. Your suggestion is duly noted and I have edited the post to reflect it.
I need to muliple a vector to every single column (as the same size of the vector) of a matrix element by element without using the for loop. Is there any way to do it?
Try using the repmat command. For example:
I visited your website and i found it very useful. Dan comments were even better. Great work!
I’ve got a question about removind some indices from a cell, e.g.
a=cell(10,10);
indicesToRemove = [3,5,8];
I want to remove both the 3th,5th and 8th columns AND rows.
such that the dimension of a is [7,7]
it doesn’t work to put these to a{ind,:}={}; a{:,ind}={}; or does it?
Percy,
Try this:
My question is -
How can I remove rows in a matrix that have third element in the column 0
Input-
1 2 3
2 3 0
0 2 3
0 2 0
Answer should be-
1 2 3
0 2 3
if I have two vectors that have different length,eg.
vector1 a=[1 2; 0 1; 2 1] and vector2 b=[ 1 2; 2 1]
and I want of delete the elements from vector1 a that have the same values with vector2 b?
without using loop, how to make a program?
assuming that I just have the vectors of a and b, but doesn’t know the index of b in a.
hey jack you can use the command
setdiff(a,b,’rows’)
Hi. I am coverting R code into Matlab and have no idea how to do the following:
>y z order(y)
[1] 1 3 8 2 5 4 6 7
> p p
[1] 0.80 3.00 0.30 0.00 0.20 1.30 9.10 0.09
How can I implement this code in matlab as there is no order() function?
Takkari,
Maybe the
sortfunction is what you are looking for.Quan
Hi Quan,
sort(y) just sort the data.
What I need is a vector containing indices of the sorted values in original vector y.
Takkari,
You could have said that in the first place, Instead of showing us the R code.
[y,i] = sort(y)
y is your new sorted values
i will be you indices
This code do the same job but takes much time:
x=sort(y);
p=[];
for i=1:length(x)
p=[p find(y==x(i))];
end
length of x is 392480
Thanks Daniel. Problem solved.
Hi Dear,
The following code is taking much time any idea how to make it run faster?
omegac,alphac,betac are scalars. h,Y,b,bb are vecotrs of of length n.
for t=3:n
h(t)=omegac+alphac*Y(t-1)+betac*h(t-1);
b(t)=Y(t-1);
bb(t)=(omegac/(1-betac)^2);
for j=2:(t-1)
b(t)=b(t)+((betac)^(j-1))*Y(t-j);
bb(t)=bb(t)+alphac*(j-1)*((betac)^(j-2))*Y(t-j);
end
end
Thanks
Takkari,
Here’s something to get you started.
Quan
Hey! I just wanted to say that your MATLAB tutorials are great, I found them extremely helpful. Everyone else’s comments were helpful as well. You have a great website!
Thanks
n=1:10;
average=mean(n)
??? Error: File: mean.m Line: 2 Column: 1
Function definitions are not permitted at the prompt or in scripts.
I got this error.How can i get mean?
How about these?
n(isprime(n))=0 returns 0 for all the primevalues of n
n(rem(n,2)==0)=0 returns 0 for all the even values of n
n(rem(n,2)~=0)=0 returns 0 for all the odd values of n
I recently found the unique(V) function very useful in a permutations algorithm which generated the correct answer several ways and stored them all. To prune it down, I used unique.
>> v=[0 0 1 1 2 2];
>> unique(v)
ans =
0 1 2
I have a matrix and I want to remove all columns that are zeros. Does anyone know how to do that?
Thanks!
Hey All,
Thanks for the useful article.
I need to access a 2-D array as a LUT.
example
LUT = [11 12 13 14; 21 22 23 24; 31 32 33 34];
rowIndex = [3 2]; columnIndex = [4 1]; % size of rowIndex equal size columnIndex
Can I get a vector of (3,4) & (2, 1) in a single command.
result = [34 21];
I got it
We can use
result = LUT(sub2ind(size(LUT), rowIndex , columnIndex ));
Hey thanks for nice tips.
I have a 2-D matrix
A = [1 2 3;4 5 6]; (A can be any arbitary matrix)
i want to sum all the elements above the value 2. How can i do that ?
i mean i want 3+4+5+6=18(answer)
Thanks a lot
hey i guess i got the answer
A = [1 2 3; 4 5 6];
% if i want to add all the values greater than 3, then
a(a<3)=0;
t=cumsum(cumsum(a),2);
t(end)
can this be reduced….
but the problem is that my ‘A’ is of type uint16/uint32.
and ‘cumsum’ is not valid for these types.
what do i do, plz susggest
thanks in advance
Hello Dr Quan Quach ,
I need a help on polynomial fit
if i have to know the 2nd order polynomial fit coefficients(c) and respective errors(e) for
x= [-1.0788 -0.8210 -0.6931 -0.3930 -0.1393 0.0198]
y= [-0.6791 -0.9390 -0.9597 -1.2373 -1.3237 -1.3737]
I used command
[c e]=polyfit(x,y,2)
i got c = 0.3207 -0.2993 -1.3736
e = R: [3x3 double]
df: 3
normr: 0.0669
actually here c is ok (as per our calculation a2 a1 a0)
but e should come as 0.13484 0.14533 0.031
could you help me how to get the coefficients errors?
Thank you
madhu
Madhu,
Have you tried using the cftool command? That might do the trick
Quan
Good stuff here. I was hoping if someone could help me with this problem that I need to get around in an efficient way (i.e I have to repeat this over many row vectors). Say, I’ve got 3 vectors :
(note the unequal dims). And I’d like to have a code that gives the following result:
Thanks in advance for any help!
Hi Baba,
Here is my idea:
Quan
Hi Quan,
I find your tips very useful and to the point. Thanks for that..
I want to know of a way to find a particular element and its corresponding index from a vector if it is greater than something. The find function usually returns all values which are greater than it, how can I just get the first number which is greater than the specified value.
For example I have a vector = [40,50,60,60,70,80,90,91,92,93];
I want to find the first element which is >90 and its corresponding index in the original vector.
If I say find (vector>90) it gives all numbers >90.
Could you help out please?
Thanks.
Adi
Hi asur,
u can use
for i=1:numel(vector)
if vector(i) > 90
index=i;
break
end
end
Hi,
I wonder if there is a built in function that would give me the number of times ‘k’ appears in a vector ? E.g. vec = [1 1 1 2 2 3 3 4 ] where k == 1
ans = 3
sorry 4got to add,
Hi,
I wonder if there is a built in function that would give me the number of times ‘k’ appears in a vector without using the hist function. ? E.g. vec = [1 1 1 2 2 3 3 4 ] where k == 1
ans = 3
Thank you very much for your help and for your time!!! thank you very much!!!
Hi asur,
you can use,
find(vector >90,1)
to get the index of the first number greater than 90 in the vector.
Hi Graham,
You could use a very simple ‘for’ loop to track how many times a number appears in your vector.
@Graham, Zane,
…OR, you could shoot the “vectorizer” at this problem. Something like:
Hope this helps! Can’t find it right now, but there is a great post by Loren about indexing that I think covers logicals like this. Also skim Steve’s blog for logical operations since they’re used in image processing a lot.
Merry Christmas!
Rob
@ Tanuj,
Since I’m on a roll with vectorizing and using logical indexing, I see you had an interesting problem farther up the page. If you need to sum up all the elements of A that are greater than 3, try this:
Read the second line as “sum up the elements of A only where the elements of A are greater than 3″
I don’t want to duplicate what Loren’s and Steve’s blogs have covered about logicals, but this method basically produces a “mask” vector of 1’s and 0’s the same size as A. It tells the sum function which elements to include and exclude from its calcs.
I also like solutions based on logicals since they very often handle whole vectors at a time, and avoid using loops. Less mess for you, and usually faster code.
HTH,
Rob
hi
how do i insert elements into an array by shifting the remaining elements to the right?
eg .
a=1:5
now insert 8 and 9 between 2 and 3 such that
a= 1 2 8 9 3 4 5
thanks
@ fawx,
Unfortunately, this will be a fairly manual operation. I would initialize a new 1D array (lets call it b) of size a + the inserts. Then fill it in with your values. Something like:
HTH,
Rob
@fawx
Rob’s method is extremely good for especially large arrays. Pre-assigning the size of arrays is good practice to improve the processing speed.
Another way, using vector concatenation would be
A few less lines, but can be harder for multi-dimensional arrays.
p.s. Thanks for the help with logicals Rob
Thanks a lot Rob S. and Zane Montgomery
that really helped a lot
fawx
Hi Dan,
Great tips !
I am stuck with a problem related to sorting of a vector:
I have following vector
vector = [1 1 0 0 0 1 1 1 0 1 1 1 0]
What I want to know is how are ones grouped together ?
In above vector they are grouped as = 2, 3, 2
How can I sort my vector this way as to reveal the groupings ..
Thank you
Rahul
In above the ans should be
ans = 2,3,3
hey great work Quan
thanks a lot
this stuff is great
Hi guys,
First let me say that I find this blog superb. Thank you for having it.
My problem consist in averaging every 10 elements of an array (G) of size 100 and storing those averages. Here is my solution:
This save me a lot of time, more than if I used a for loop instead, but still I would like to improve it further if possible. Do you guys have another suggestion?
Thank you.
Hello everyone, I’m sorry if this has already been answered, but is there no built-in function that returns the elements you remove from an array? Example:
a = [1,11,111]
I want to return element 2 and 3 to create an array b, leaving a with only its’ first element intact:
a == [1]
b == [11,111]
Any such operator or do I need to create it myself? I’m not a programming guru so I’m not certain how to create this functionality in the most efficient way.
Thanks in advance, I’m sure someone has a great answer to a beginner such as myself ^^
to create logic gates by using matlab,program.
Hi Matt,
What you could do is before removing some elements of a(:), store them in another vector b(:). I solved your example here:
You can do more complicated stuff, for instance if you want to remove the elements of a(:) equal to 11:
-Yo
We have a vector with some values given by a function. We want to duplicate this vector N times, so we get a 2 dimensional matrix.
Eg,
{ 1 0 1 0 0 1 } Our vector
After the operation we want this result:
1 0 1 0 0 1
1 0 1 0 0 1
1 0 1 0 0 1
1 0 1 0 0 1
.
.
.
(N) times
Our try:
But this doesnt give us a 2 dimensional matrix.
Thanks in advance
@Johan&Jeppe,
I’m curious if the matrix you’re getting is 1-D or 3-D+? I would think it should still output as 2-D, just not the style that you want.
Let’s call your vector ‘a’. Since you want to make a new matrix that is a column vector of many ‘a’ vectors, your repmat should be repmat(M,N,1) where N is the N times you wanted above (aka ‘r’ in your code)
This will stack the matrix/vector on top of itself r times. Hope that helps!
-Zane
Thanks Zane for the quick response, this solved our problem.
How do I return the, say, first element of an array expression without storing the
expression into a temporary variable first? Eg
Hi .. Its really usefull wesite.. I need to know how to get the average of group of vectors…Lets say we have:
A=[1 3 5]
B=[4 7 1]
C=[8 9 0]
is there anyway to get the average of A,B and C??
I wanted to insert the zero column vector in the matrix. I have this matrix
[1 0 0 1
0 0 1 1
1 1 1 0
0 1 0 1]
How do I convert it to
[1 0 0 0 0 0 1 0
0 0 0 0 1 0 1 0
1 0 1 0 1 0 0 0
0 0 1 0 0 0 1 0]
Thanks
Hi Quan,
Thanks for all of the tips. I HATED shifting vectors! It’s not practical in most cases. Quan, you should check out the circshift command… it’s easy and you just enter the ammount that you want the vector shifted (you do however, have to convert the vector into a colum vector…):
hey,
i’ve done a blunder by performing a set of operations on the wrong array, due to typing error. The array content has now changed..i.e. its size has increased and values modified.Is there any way to rollback this to the original state? or do i have to recode by rote? there’s really lengthy stuff preceeding it..
thanks,
nirveda
How would I create a 200 by 100 array
Now
how would i filled the values of this array to
[1 2 3 4 .....
101 102 103...
201 202 203
]
jose velez:
To create 200 x 100 array:
To fill it in with what you wanted:
There might be a better way than the for loop, but this will do the job quite nicely.
The issue: I have two arrays filled with important data.
Array1 is an array of size 31 x 31 array
Array2 is an array of size 31 x 21
I tried this but it only it only if the array is 1 dimensional.
for i=1:9,
t = [t 0];
end
Example
array= [1 2;
1 2;]
how do i transform the previous array to look like
array =[1 2 0 0 0;
1 2 0 0 0;]
Keep in mind I cant do it manually it has to be by MATLAB code because is a 31 x 31 array ( lots of numbers)
Thank you for your efforts.
Jose,
Try this out:
This concatenates a zero array of size 31×10 after you original 31×21 array2. You can play around with that, but it is very specific on dimensions of each array. This can also be expanded/parametrized for an MxN array –> MxM array. Good luck!
-Zane
That worked Zane you are a genius.
oops forget to fill my name…thx be4 guys.
Hi Budhie,
Somethings wrong with your ‘if’ statement, but that’s not how I usually code in MATLAB, but let me show you a cool tip.
It looks like you’re just trying to convert the original winddir vector from degrees to radians and then taking the N/S (cosine) component of it?
Two ways to do that:
But even easier, MATLAB has built in capability to handle degree measurements:
cosd(),sind(),tand() are your functions if your angle is in degrees.
And to get your desired solution:
That got me what you were looking for, hopefully it works for you too.
-Zane
HI Zane,
its works, thanks for the cool tips :D. yes i want to separete the wind component. but i still have problem doing operation in array.
i want to do something like this :
thx be4,
-budhie-
hmm the matlab code doesn’t properly display my code…
a = [1,2,3;4,5,6;7,8,9] %wind speed
b = [30,60,120;135,180,210;225,250,300] % wind direction
% i want to do operation between 2 array, but only on wind direction selected value and keep other value in array a that not selected.
% how i can do that in matlab?
if (b >=90)&(b=180)&(b<270)
a = a*cosd(b-180)
end
end
%expected results in 3×3 array
a = [1,2,2.59807;2.82842,-5,-5.19615;-4.94974,-2.73616,9]
thx be4,
-budhie-
sry if double posting…:D
if (b >=90)&(b=180)&(b<270)
a = a*cosd(b-180)
end
end
if (b >=90)&(b=180)&(b<270)
a = a*cosd(b-180)
end
if (b >=90) & (b<180)
a = a.*sind (b-90)
else if (b >=180)&(b<270)
a = a*cosd(b-180)
end
end
sry doesn’t display m if correctly…
thx be4,
-budhie-
How do I make a plot using h=pcolor for 210×1 matrix
Hello,
I am relatively new to Matlab, and I am looking to a solution for.
I have a matrix for e.g.
A = [ 2.1 1.2 2.3 1.3 1.3 3.4 5 2 6 8.4 5.4 5.4 3.4 5 2 4.4 2.2 4.5]
now there appears 3.4, 5 and 2 twice consecutively in the above code, and I see it as a pattern. I need some solution to extract these values at a certain min threshold to max threshold sequence.
So, how can i do it to extract a particular pattern out of the code.
Alternatively I have seen in this very useful blog that values greater than / less than in a vector can be replaced by some, but is there some solution that a block of values be replaced by some value for e.g. all values greater than 3 and less than 7 be changed to 0 in a vector.
I will highly appreciate help in this regards,
/Malaika.
I have 2 vectors say a = [1 2 3] and b= [4 5 6]. I want to do something like this
c(1) = min( a(1) - b(1), a(1) - b(2), a(1) - b(3));
c(2) = min( a(2) - b(1), a(2) - b(2), a(2) - b(3));
c(3) = min( a(3) - b(1), a(3) - b(2), a(3) - b(3));
Can i do this without using loop with the help of array indexing or vectorising?
hi,
Is there a efficient way to replace all values in the array that is greater than 0 with 1s and rest with zeros while maintaining the dimensions of the array.
e.g. a={ -1.2, 0.12, 1.5 , -0.009, 2} to a={ 0,1,1,0,1}
great site by the way.
Tim,
I’d recommend creating a new variable b to store you 0s/1s array, but other than that it’s easy.
And you’re done!
2 quick notes:
1) B is an array of logicals
2) Make sure you’re using ‘array’ notation ‘[ ]‘, not ‘cell’ notation ‘{ }’ The cells is an array of 1×1 arrays and you’ll have to access each element individually to evaluate.
Good luck,
Zane
@ malaika some pseudocode : you could try to get indices
find occurences of first value and sav index array
idx = find(args(1)) and loop
add + 1 after each cycle to the idxold+1 (6 13) => idxnew (7 14) and so on
test next argument like this (you can take length, sum, mean or numel of idx array)
if mean(A(idxnew)) == val2 continue and increment pattern counter
else break
loop condition then would depend on flexibel vector length 3.4 5 2 …
testvector = vect(1:pos)
hope it was helpful
hi everyone ,
This website is really useful for us. plz i need a help . How to group an array elements within range. plz help me.