probably there is a best solution but this works for me..
Anyway I look forward to hearing your hints
"Mario " <nospam@yahoo.com> wrote in message
<g2p1ca$8sa$1@fred.mathworks.com>...
> Hi.
> I want to test an algorithm with different values for the input variables.
>
> I thought to call my function inside a for loop but i want to increment the
> input variable with a inconstant increment.
>
> e.g.
> for i=0.0001:i:1
> test(i)
> end
>
> so the first call would be test(0.0001), the second one test(0.0002), the
third
> one test(0.0004), then test(0.0008) and so on.
>
> I tried also the following way
> i=0.0001
> for j=0.0001:i:1
> test(j)
> i=j; % or i=2*i;
> end
>
> but it doesn't work!
> Any help?
>
> Thank you,
>
> Mario
In article <g2p1ca$8sa$1@fred.mathworks.com>, Mario <nospam@yahoo.com> wrote:
>I want to test an algorithm with different values for the input variables.
>I thought to call my function inside a for loop but i want to increment the
>input variable with a inconstant increment.
>e.g.
>for i=0.0001:i:1
> test(i)
>end
You can't do that with a 'for' loop.
>so the first call would be test(0.0001), the second one test(0.0002), the third
>one test(0.0004), then test(0.0008) and so on.
>I tried also the following way
>i=0.0001
>for j=0.0001:i:1
> test(j)
> i=j; % or i=2*i;
>end
>but it doesn't work!
The 0.0001:i:1 part will be logically evaluated first, as if it
produced a vector of values, with j then being sequenced through that
vector of values.
Use a while loop instead.
i = 0.0001;
while i <= 1
test(i);
i = i * 2;
end
--
"There is nothing so bad but it can masquerade as moral."
-- Walter Lippmann
"Mario " <nospam@yahoo.com> wrote in message <g2p1ca$8sa
$1@fred.mathworks.com>...
> Hi.
> I want to test an algorithm with different values for the input variables.
>
> I thought to call my function inside a for loop but i want to increment the
> input variable with a inconstant increment.
>
> e.g.
> for i=0.0001:i:1
> test(i)
> end
>
> so the first call would be test(0.0001), the second one test(0.0002), the
third
> one test(0.0004), then test(0.0008) and so on.
>
> I tried also the following way
> i=0.0001
> for j=0.0001:i:1
> test(j)
> i=j; % or i=2*i;
> end
i has to be an integer.
Try:
for i =1:1000
test(i*.0001)
end
In article <g2p2c7$mia$1@fred.mathworks.com>,
Sean <sean.dewolski@Idontwantspam.umit.maine.edu> wrote:
>"Mario " <nospam@yahoo.com> wrote in message <g2p1ca$8sa
>$1@fred.mathworks.com>...
>> for i=0.0001:i:1
>> test(i)
>> end
>> i=0.0001
>> for j=0.0001:i:1
>> test(j)
>> i=j; % or i=2*i;
>> end
>i has to be an integer.
Where did you get that idea??
doc for
for x=initval:stepval:endval, statements, end is the same as the
above syntax, except that loop counter x is incremented (or
decremented when stepval is negative) by the value stepval on each
iteration through the loop. The value stepval must be a real number
or can also be a call to a function that returns a real number.
--
"Do not on any account attempt to write on both sides of
the paper at once." -- Walter C. Sellar
> for i=0.0001:i:1
> test(i)
> end
> so the first call would be test(0.0001), the second one
test(0.0002), the third one test(0.0004), then test(0.0008)
and so on...
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central.
Read the complete Terms prior to use.