myColon - end elseif sv<0 %this elseif statement...

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

View Full Document Right Arrow Icon
function vec = myColon(iv,sv,fv) %function to output a vector in the same way the colon operator would given %the same input values %usage: vec = myColon(iv,sv,fv) %vec=iv; %in order to begin with the initial value, vec must equal iv outside the %loop %z = iv; %z must equal the iv in order to prevent the loop from going one step too %far if sv>0 %this if statement accounts for positive step increments vec = iv; z = iv; while iv<fv %this condition will make sure that my initial value is less than or %equal to the final value minus the initial iv while continuously adding the step factor to %the new initial value vec = [vec iv]; %this sets vec equal to whatever the new initial value is iv = iv + sv; %this continuously adds the step factor to the new initial value
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: end elseif sv<0 %this elseif statement accounts for negative step increments vec=iv; %vec must equal iv in order to get the initial value z=sv; %z must equal sv in order to prevent the loop form going one step too %far while (fv-z)<iv %this condition will make sure that my final value minus the %negative increment is less than the initial value while %continuously adding (subtracting) the step value to the initial %value iv = iv + sv; vec = [vec iv]; %this sets vec equal to whatever the new initial value is end elseif sv==0 %this elseif statement accounts for zero step increments vec=; %the resulting vector will be empty, because no steps are taken end...
View Full Document

This note was uploaded on 10/21/2010 for the course CS 1371 taught by Professor Stallworth during the Spring '08 term at Georgia Institute of Technology.

Ask a homework question - tutors are online