{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

ABCs_vectors

# ABCs_vectors - located(F E=min(vec F=vec(E Sort the vector...

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

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 = linspace(1,2,n); A % Create a vector, B, that goes from 12 to n in steps of 4. Use the % colon operator. B=12:4:n; % Create a vector, C, consisting of n 391s. ([391 391 391. ..]). Use the % zeros or ones function. C=zeros(391,n); % 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). D=length(vec); % Find the smallest element in vec (E), and the index at which it is
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % located (F). E=min(vec); F=vec(E); % Sort the vector vec and store it in (G). G=sort(vec); % vec2 is also a vector. Concatenate vec and vec2 in that order (H). H=[vec vec2]; % Reverse vec2 and store the resulting vector in (I). I=fliplr(vec2); % Find the last element of vec2 (J). Do it without using the length % function. J=vec2(end); % 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). K=vec2(1:2:length(vec2)); % Find all of the numbers in vec2 that are less than 5. (L) x=find(vec2<5);...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online