Prev: how to calculate DC gain of Transfer Fucntion
Next: An exact 1-D integration challenge - 65 - (sqrt, cos)
From: Jerry Walker on 10 Jul 2010 13:15 I would like to build an array of unspecified length by using the following input method: input('Input a value for n greater than or equal to 1. If complete enter 0 '); The length of the array is to specified and the array completed by entering zero. Can this be done?
From: us on 10 Jul 2010 14:30
"Jerry Walker" <tateshell(a)yahoo.com> wrote in message <i1a9qs$789$1(a)fred.mathworks.com>... > I would like to build an array of unspecified length by using the following input method: > > input('Input a value for n greater than or equal to 1. If complete enter 0 '); > > The length of the array is to specified and the array completed by entering zero. Can this be done? one of the very many solutions - here, we use a ...reasonable... preallocation scheme... n=1024; % <- use your prealloc number... v=nan(1,n,'double'); for i=1:n vt=input('enter a number -or- end with a 0 < '); if vt==0 break; end v(i)=vt; end v=v(1:i-1); disp(v); us |