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) if sv>0 %this if statement accounts for positive step increments vec=[]; 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&lt;0 %this elseif statement accounts for negative step increments vec=; while fv&lt;=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 vec = [vec iv]; %this sets vec equal to whatever the new initial value is iv = iv + sv; 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

Ask a homework question - tutors are online