ABCs_vectors

ABCs_vectors - % % Find the smallest element in vec (E),...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function [A B C D E F G H I J K L] = ABCs_vectors(n, vec, vec2) f % Create a vector, A, that consists of n equally spaced numbers between 1 % and 2. Use linspace. A = A % Create a vector, B, that goes from 12 to n in steps of 4. Use the % colon operator. % % Create a vector, C, consisting of n 391s. ([391 391 391. ..]). Use the % zeros or ones function. % % vec is a vector with at least 5 elements (numbers). Find the following % and store them in the indicated variables. % Example. Find the second element of vec (Z). Z = vec(2); Z % Find the number of elements in the vector vec (D).
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % % Find the smallest element in vec (E), and the index at which it is % located (F). % % Sort the vector vec and store it in (G). % % vec2 is also a vector. Concatenate vec and vec2 in that order (H). % % Reverse vec2 and store the resulting vector in (I). % % Find the last element of vec2 (J). Do it without using the length % function. % % Starting with the first element, find every other element in vec2. That % is, find every element in vec2 that occurs at an odd-numbered index (K). % % Find all of the numbers in vec2 that are less than 5. (L)...
View Full Document

Ask a homework question - tutors are online