Message Boards Message Boards

0
|
6593 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

How to save a value after each turn of a For loop?

Posted 9 years ago

Hi guys I have a expression like this one :

Q[r_ , ri_] := {DiracDelta[r - ri], 5*DiracDelta[r - ri]  , DiracDelta[r - ri]^2 ,  Derivative[1][DiracDelta][r - ri]}

my ri is a list of following numbers: ri = {-0.5 , -0.2 , 0.5 , 0.5} now I want to introduce a new symbolic function as S[r_ , ri[ which is the same like Q[r , ri_] but with some chamges in the expressions. So I used this command:

For[i = 1 , i <= FromDigits[Dimensions[Q[r , ri]]] , i++ , 
 QI[r , ri[[i]]] = 
  Q[r , ri[[i]]] /. 
   DiracDelta[r - ri[[i]]] -> HeavisideTheta[r - ri[[i]]]]

But the Problem is the for loop function just applys the changes of the last iteration and does not save the loop after each turn. Since this is so important for me, any possible answers are appreciable.

POSTED BY: Mohsen Rezaee
Posted 9 years ago

basically, what you have is something like

f[x]:={g1[x],g2[x],g3[x],g4[x]}

or, to put it in words, you have a vector (f) whose components are dependent on a parameter (x) in various ways (the different g's)

now, if I understand correctly, what you want to do is something like

f@{-0.5 , -0.2 , 0.5 , 0.5}

but before that it would help if you had also started like so

SetAttributes[f, Listable]
POSTED BY: nik tsak
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract