Question

Use the rep function to create a vector that has the following elements: 2.7 8.0 3.0...

Use the rep function to create a vector that has the following elements:

2.7 8.0 3.0 2.7 8.0 3.0

0 0
Add a comment Improve this question Transcribed image text
Answer #1

> x<-c(2.7,8.0,3.0,2.7,8.0,3.0)
> rep(x)
[1] 2.7 8.0 3.0 2.7 8.0 3.0
> rep(x,2)
[1] 2.7 8.0 3.0 2.7 8.0 3.0 2.7 8.0 3.0 2.7 8.0 3.0

here rep(x,2) 2 represent the number of times repetation of vector x

Add a comment
Know the answer?
Add Answer to:
Use the rep function to create a vector that has the following elements: 2.7 8.0 3.0...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • in c++ 3- Create a vector of integers and do the following: a- Create fillVector function...

    in c++ 3- Create a vector of integers and do the following: a- Create fillVector function that uses the push_back method provided by the vector class to fill the vector with random numbers (use rand). b- Now implement the void addNumbers(vector &data) method that adds 10 numbers to the data vector (use a for loop). c- Create a new function void print_even(const vector& data) that prints all of the elements in the data vector that are stored at an even...

  • MATLAB Create a row vector vC=2:3:38 that has 13 elements. Then, create the following new vectors...

    MATLAB Create a row vector vC=2:3:38 that has 13 elements. Then, create the following new vectors by assigning elements of vC to the new vectors: (a) A vector (name it vCodd) that contains all the elements with odd index of vC; i.e., vCodd = 2 8 14 ... 38. (b) A vector (name it vCeven) that contains all the elements with even index of vC; i.e., vCeven = 5 11 17 ... 35. In both parts use vectors of odd...

  • MATLAB ASSIGMENT 1. A. Create a function called ch16initials3 Input: row vector of 101 values (Note:...

    MATLAB ASSIGMENT 1. A. Create a function called ch16initials3 Input: row vector of 101 values (Note: input values are specified in the function call) Output: calculated maximum value Create a row vector A of values from 50 down to 0, with an increment of 0.5 Multiply the elements of A and the square of the elements of the input vector Store the results in B Find the maximum value of B and store it in C – this is the...

  • 4. Create a variable N that is a column vector with seven equally spaced elements in...

    4. Create a variable N that is a column vector with seven equally spaced elements in which the first element is 44 and the last element is 23. 5. Create the following three row vector: a=[5 8-10 2], b=[4 19 -2 3], and c=[-35 06 1]. a) Use the three vectors in Matalb command to creat 3x5 matrix in which the rows are the vectors c, b and a, respectively. b) Use the three vectors in a Matalb command to...

  • Use C Create a function that will take in a vector (three double variables) representing a...

    Use C Create a function that will take in a vector (three double variables) representing a position in meters. Calculate the magnitude of the vector in meters: sqrt(x * x + y * y + z * z) Calculate the magnitude of the vector in feet: magnitudeInMeters * 3.28084 Using passing by reference, return both outputs from the same function. Input: Three unique doubles, each one representing a component of the vector. Output: Magnitude of the vector in meters, magnitude...

  • Create a new function file and write a function s= SUM_EVEn_ ubitname(V) that takes a vector...

    Create a new function file and write a function s= SUM_EVEn_ ubitname(V) that takes a vector V of arbitrary length and determines the sum of the even element and assign it to s. your function calculations must do the following: * Use a loop that iterates through every element of V and adds s only even element and skips all other elements. * Contain the appropriate H1 and help text lines. * Note: A number is even, if round(number/2) is...

  • Problem 5 Create the following matrix by typing elements explicitly one command. Do not type individual...

    Problem 5 Create the following matrix by typing elements explicitly one command. Do not type individual 0 00 0 0 o o 0 0 0 0 0 1 2 3 F=0 01 10 20 0 0 2 8 26 0 0 3 6 32 E 0 045 6 0 0 7 8 9 Problem 6 Create two row vectors: a -4 10 0.5 1.8 -2.3 7, b [0.7 9 -53-0.6 12 (a) Use the two vectors in a MATLAB command...

  • Assume that y is a column vector with ten elements, write matlab code that will create...

    Assume that y is a column vector with ten elements, write matlab code that will create a stem plot of the vector starting at a horizontal axis value of 1. Add code that will create the stem plot of the vector starting at a horizontal axis value of 0. Create additional code that creates a stem plot but plots y at every other horizontal value (i.e., 0, 2, 4, etc)

  • can anyone help with a MatLab code? Problem create a function that takes in the following...

    can anyone help with a MatLab code? Problem create a function that takes in the following vector DATA and returns the number of elements, the mean and the sum of the elements. You can call the function ANALYZER DATA [2 4 5 6 7 8];

  • Use the rbinom() function to create a vector of 1000 random observations from the binomial distribution...

    Use the rbinom() function to create a vector of 1000 random observations from the binomial distribution with n=100 and probability of success is equal to 0.4. Calculate the mean and standard deviation statistics for this vector of random draws using the mean() and sd() commands. How do these numbers compare the mean and standard deviation of the binomial distribution when  and ? If they are different, why? Make a histogram of this vector using the hist() command.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT