**question on function in a function**If I have a function A.m which will be excecuted 10 times.
In this function there is another function B.m How can I
just excecute B.m only during the first time A.m is
called? i.e. if A.m is called for the second time , B.m
will not run.
Thank you for any help
Mike
One way to do this is to use a persistent variable in A.m:
function A(arg1)
persistent first_call
if isempty(first_call)
% call function B.m here
first_call = 0; % initialize so it will no longer be empty
end
% do rest of function A() here
end
Note that this mechanism will be reset if you run the clear command, e...

**Question on function functions**I want to use the quad command to integrate a user defined function
which takes 3 variables as inputs. Two of these variables are
parameter values which will be given. I want the computer to
integrate over the third variable. How do we do this in Matlab?
Thanks.
By the way, I used Matlab 6, r12.
thanks.
Onur wrote:
>
>
> I want to use the quad command to integrate a user defined
> function
> which takes 3 variables as inputs. Two of these variables are
> parameter values which will be given. I want the computer to
> integrate over the third variable. How do we do this ...

**Rexx time() function question**I know I can use the date() function to calculate and format a future
date ie.
today = date('Base')
futureday = today + 15
futuredate = date(, futureday, 'Base')
My question is, can I do something similar with the time() function?
I want to add some seconds to the number of seconds since midnight and
format the time.
now = time('Seconds')
futuresec = now + 150
futuretime = time(, futuresec, 'Seconds')
I get the following error
93 +++ futuretime = time(, futuresec, 'Seconds')
IRX0040I Error running TESTTHIS, line 93: Incorrect call to routine
Can any...

**C Program Question**I am doing the following in my C program
clock_t tstart, tend;
tstart = clock();
/* ................
Body of Code
............... */
tend = clock();
runtime = ((double) (tend - tstart) / (double) CLOCKS_PER_SEC);
I am getting negative values for runtime. Any suggestions where I am
going wrong?
Thanks for the help.
- R .
Raj <rajeev.namboothiri@gmail.com> wrote:
> I am doing the following in my C program
> clock_t tstart, tend;
> tstart = clock();
> /* ................
> Body of Code
> ............... */
> tend = clock();
> runtime = ((double) ...

**I do it for charity: The answer to the how do I talk in polynomial time question is this is question time polynomial in talk I do how the to answer the:!?**The answer to the how do I talk in polynomial time question is this is
question time polynomial in talk I do how the to answer the:!?
http://meami.org
'Do it for the kids!'
...

**function function question from a newbie**please forgive and be kind to this call for help.
I'm trying to script a web survey and I'm not having any luck.
Specifically, the survey is composed of eight questions (two will be
given in the sample below) and the possible responses are:
a) approve the measure
b) no opinion
c) object to the measure.
I am trying to create a function script whereby if the user chooses
(c) object, he had to elaborate on that by choosing one of four
possible flavors:
a) the project is not sound
b) the project duplicates a previous project
c) the project is not needed
d) other - which gives the user ...

**How can I use a Matlab function, whose inputs varies with time (real time function), in simulink**Hello
I need your help
I would llike to know how can I use a Matlab function, whose inputs varies with time (real time function), in simulink.
Thank you in advance
Hiba
...

**GTM External Functions Date Time Questions**Hi all,
Thinking about extended DateTime functions for GTM programs.
First limitation seems to be that we have days and seconds but no
milliseconds in a $H variable.
This isn't particularly helpful for accurate timing of functions /
modules.
Would a GetDateTime function be useful that returned Horolog format in
[days],[second].[milliseconds]?
Would you want to do this in "current locale" and also in "UTC"? For
example: Log files, events recorded in UTC?
Would a string DateTime format of [Century][Year][Month][Day]T[Hour]:
[Min]:[Sec].[milliseconds] be useful ie: like...

**question about functions generating functions**Hi group,
I'm interested if there's another way than using eval in this
situation: a code has to be generated (and compiled) at run-time. Say,
to solve a sparse system of equations x=Ax+b using an iterative
algorithm I might have a specific function to compute Ax+b with A, b
hard-coded inside. I mean, not having a matrix A and a vector b
explicitely. If A, b were known at compile-time, we'd use macros. But
what if A, b have to be computed at run-time? I can construct nested
lists representing a lisp function to compute Ax+b and feed it to
eval.
My question, are there other techniqu...

**Question re FUNCTION SECONDS-FROM-FORMATTED-TIME**What is supposed to happen if the content of arg-2 does not agree
with the format in arg-1 ?
eg.
arg-1 "hhmmss"
arg-2 "13:30:01"
Roger
"Roger While" <simrw@sim-basis.de> wrote in message
news:eoj0ui$bpd$02$1@news.t-online.com...
> What is supposed to happen if the content of arg-2 does not agree
> with the format in arg-1 ?
> eg.
> arg-1 "hhmmss"
> arg-2 "13:30:01"
ISO/IEC 1989:200x WD 1.6, page 601,
"The rules for a function may place constraints on the
permissible values for arguments in order to permit
mean...

**questions about functions inside a function**I want to create a list of function.
Here is my code:
In [9]: a = []
In [10]: for i in range(4):
....: b = lambda : i**2
....: a.append(b)
....:
....:
In [11]: for f in a:
....: f()
....:
....:
9
9
9
9
What I want is, the value of i should be bounded to the anonymous function.
And the output should like this:
for f in a:
print f()
0
1
4
9
How to achieve this?
Thanks a lot!
Jeremy Sanders a �crit :
> fdu.xiaojf@gmail.com wrote:
>
>
>>What I want is, the value of i should be bounded to the anonymous
>>function. And th...

**Itertools question: how to call a function n times?**I want to write a function that each time it gets called, it returns a
random choice of 1 to 5 words from a list of words.
I can write this easily using for loops and random.choice(wordlist) and
random.randint(1, 5).
But I want to know how to do this using itertools, since I don't like
manually doing stuff like:
phrase = list()
for i in random.randint(1, 5):
phrase.append(random.choice(wordlist))
It just seems slow.
All advice welcome.
TIA
Matt
--
A better way of running series of SAS programs:
http://tplus1.com/wilsonwiki/SasAndMakefiles
Matthew Wilson a �crit ...

**Easy question, please help to run a function n times**I am trying to run the function t= M/(R/n), where R is a random number generated between 15 and 25. What function do i use to run this simulation 10,000 times and calculate the mean and std error from 306.
This is what i have so far
M=74
n=88
No=306
R= RandomReal[{15,23}]
t= M/(R/n)
t = x; Do[t = M/(R/n), {10000}]
Everything is working for me except how to run the simulation 10,000 times
M = 74;
n = 88;
No = 306;
R = RandomReal[{15, 23}, {10000}];
t = M/(R/n);
mu = Mean[t]
348.482
No - mu
-42.4819
StandardDeviation[t]
43.0218
Bob Hanlon
---- Kev...

**Question on tools or functions for checking most time consuming part of code**Hello:
I have a Matlab code that takes long in the first time of running, but
less time in later executions. I don't know why that happened. The
code contains GUI and mathematical calculations, so I would like to
trace which part of the code cost most of the time and then check why
it costs more in the first time run. However, I only know use tic and
toc to do that, and it will be tedious to add them in all part of the
code.
Is there a tool or function for Matlab that can automatically trace
which part of the Matlab code is the most time consuming?
Any help will be appreciated.
"...

**Xilinx PDR flow questions**Hello, just some questions concerning the EAPR flow for Xilinx..
The examples related to the EAPR allow to access the bitstreams stored
in a compact flash (SystemACE) .. Has any body any experience in
moving the bitstreams to a DDR RAM initially and let the ICAP access
the bitstreams from there .. ? What are the advantages and
disadvantages ..
Also i would like to know if there are any C functions that i can add
to the processor code to print out the reconfiguration time between
the switching of the bitstreams ?
Thanks
Quadri
...

**Re: Easy question, please help to run a function n times**On 5/7/10 at 6:28 AM, kxcarmichael250@hotmail.com (Kevin) wrote:
>I am trying to run the function t= M/(R/n), where R is a random
>number generated between 15 and 25. What function do i use to run
>this simulation 10,000 times and calculate the mean and std error
>from 306.
>M=74
>n=88
>No=306
>R= RandomReal[{15,23}]
You do not want to use Set here. with this code,
RandomReal[{15,23}] will evaluate and the result will be assigne
to R. All future references to R will use this value, not a new
random value. To get a new random value every time R is used
...

**Re: Easy question, please help to run a function n times #2**I would use a FOR loop and collect the generated points in a preallocated
vector like,
M=74;
n=88;
T = Range[10000];
For[i=1, i<=10000, i++,
R= RandomReal[{15,23}];
T[[i]]= M/(R/n);
];
myMean = Mean[T];
However, this is very much a procedural programming approach. I'm sure the
Mathematica experts helping on this list can provide a more efficient
approach...
Joe
On Fri, May 7, 2010 at 6:28 AM, Kevin <kxcarmichael250@hotmail.com> wrote:
> I am trying to run the function t= M/(R/n), where R is a random number
> generated between 15 and 25. Wh...

**Re: Easy question, please help to run a function n times #3**On 5/8/10 at 7:08 AM, hays.joe@gmail.com (Joe Hays) wrote:
>I would use a FOR loop and collect the generated points in a
>preallocated vector like,
>M=74;
>n=88;
>T = Range[10000];
>For[i=1, i<=10000, i++,
>R= RandomReal[{15,23}];
>T[[i]]= M/(R/n);
>];
>myMean = Mean[T];
>However, this is very much a procedural programming approach. I'm
>sure the Mathematica experts helping on this list can provide a more
>efficient approach...
One thing about efficiency.
Doing:
myMean = Mean[M/(RandomReal[{15,23}, 10000]/n)]
is far m...

**Question about real-time timing simulation**I am doing real-time image processing with VHDL. But I am not quite sure
how I simulate the system with an input image.
Basically, an image processing system takes input data from an image
source, then does some work, finally output the result.
Once I have the vhdl project compiled, for the waveform timing
simulation, how could I input data of a 512x512 image as a real-time
environment. I don't think I should save the whole image data matrix in
some embedded memory blocks.
Someone told me that I can try test bench. But I have no idea about
that. Can someone give a quick guide or sug...

**Time Function gives Incorrect Time**Hello
I have a win32 c++ application that shows a map of the world & the
local time at a selected city. But for some reason the local time is
all random numbers when it was showing the correct time before with my
function.
I changed some things so you could select 12hr or 24hr time format but
I cant see why my local time is not working now. Can you help me see
why the time function broke.
[b]This is my application before I made the changes & the time
works(is correct):[/b]
http://www.mediafire.com/?nlmmzdzz3y4 - 120kb
[b]And here is the latest version of the app wher...

**time module question**I tend to deal with dates a lot in different formats and places...
typically I'll convert them to a time tuple with strptime(), and pass
them around like that before I need to write them back out.
One set of time/dates I'm getting are in UTC, but the string doesn't
say that specifically. So I do this.. I had expected the outcome to
be offset properly (I'm EST5EDT). But I'm obviously missing
something:
#!/usr/bin/env python
import time
utc_str = '2008-05-10 03:05:00 UTC'
d = time.strptime(utc_str,'%Y-%m-%d %H:%M:%S %Z')
t = time.mktime(d)
print d
pri...

**How to apply a function to a function multiple times**Hi,
I have the following code.
iterater[hPrev_] := Integrate[Sqrt[1 + Derivative[1, 0][hPrev][x, t]^2], t]*v[x]
h0[x_,t_]:=0
h1[x_,t_]:=iterater[h0]
h2[x_,t_]:=iterater[h1]
h3[x_,t_]:=iterater[h2]
I want to code another function,
fun[h0_,v_,n_]
where n is the times "iterator" has been applied.
fun[h0,v,3] should give me h3[x_,t_] defined above.
fun[h0,v,4] should give me iterator[h3].
Can you show me how to do it?
Thank,
Peng
Hi,
have you tried with Nest[] command?
http://documents.wolfram.com/mathematica/functions/Nest
S.
"Peng Yu" &...

**Time Function gives Incorrect Time**Hello
I have a win32 c++ application that shows a map of the world & the
local time at a selected city. But for some reason the local time is
all random numbers when it was showing the correct time before with my
function.
I changed some things so you could select 12hr or 24hr time format but
I cant see why my local time is not working now. Can you help me see
why the time function broke.
[b]This is my application before I made the changes & the time
works(is correct):[/b]
http://www.mediafire.com/?nlmmzdzz3y4 - 120kb
[b]And here is the latest version of the app wher...

**19990823: General announcements. Goedel's question: if a theorem has a proof of length at most n, can we find it in time O(n^2)? Another question on what can be computed in limited time and sp**19990823: General announcements. Goedel's question: if a theorem has a
proof of length at most n, can we find it in time O(n^2)? Another
question on what can be computed in limited time and space. Overview
of related topics from courses on algorithms, theory of computation,
formal logic. Definition of composite. Definition of prime. Examples.
The primality problem. Some representations of integers: decimal;
binary; unary; factored. The importance of specifying the input
representation. Simple algorithm for the primality problem. Time for
dividing n-digit numbers. Overall time for simple al...