Post Reply 
Dynamic Variable(s)....Help??
11-18-2016, 05:36 PM (This post was last modified: 11-18-2016 05:37 PM by toshk.)
Post: #1
Dynamic Variable(s)....Help??
how can i create a dynamic variable.?
Application:
in circuit simulation application (eNet) http://www.hpmuseum.org/forum/thread-7015.html i was able to generate a column dynamic matrix (nkll) for a given network.
nkll consist of node voltages and currents thru a branch variables. (but they were never declared as a variables in the application );
now i want to assign values (solutions) to nkll matrix in the application....help?
the goal here is designing a scope for these nodes:
Find all posts by this user
Quote this message in a reply
11-20-2016, 05:49 PM
Post: #2
RE: Dynamic Variable(s)....Help??
Suppose M is the matrix.
Then you can treat M(i,j) as variables.
So in my opinion there is no need to create extra variables.
Find all posts by this user
Quote this message in a reply
11-21-2016, 06:54 AM
Post: #3
RE: Dynamic Variable(s)....Help??
Hello,

You can create variable dynamically using HVars and AVars, However, in your case here, what you most likely need is the creation of one single variable that will contains an indexable number of variables.

If your data is purely numerical (reals or complex), a matrix will work. Else, you can use a list.

Cyrille

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
11-21-2016, 10:49 PM (This post was last modified: 11-21-2016 11:06 PM by toshk.)
Post: #4
RE: Dynamic Variable(s)....Help??
(11-21-2016 06:54 AM)cyrille de brĂ©bisson Wrote:  Hello,

You can create variable dynamically using HVars and AVars, However, in your case here, what you most likely need is the creation of one single variable that will contains an indexable number of variables.

If your data is purely numerical (reals or complex), a matrix will work. Else, you can use a list.

Cyrille
... this is my work around for dynamic variable(s) that exist with their variable names.
with cas: create a dummy variable(s ) with expr, string syntax and assign zero to it. then use these dummy(s) which now exist in cas world in home/cas.
example is provided below...in my circuit case I know the number of node(s) hence create v1, v2....vn. I also know the paths hence I can create potential difference label as v1v2, v3v4.....and for current create j1j2, j3j4.....
a modification of this code dumber() with arguments can be tailored to ones need for special variables in Solver app; equation Library and etc.

#cas
dumber() //creating 10 dummy variables of f and vnvn
BEGIN
local k, ss;
FOR k FROM 1 TO 10 DO
ss:=left(STRING(k),10);
expr("f" +ss +":=" +0); //dummy f1,f2....f10
expr("v" +ss +v + ss +":=" +0); //dummy v1v1, v2v2....v10v10
END;
END;
#end
Find all posts by this user
Quote this message in a reply
11-21-2016, 11:31 PM
Post: #5
RE: Dynamic Variable(s)....Help??
now I have all these dynamic variables....
efficient way to delete them or purge them when not needed....help?? efficient app function.
example....
if I do create say v1...v10 for 10 node circuit with their calculated values assigned. and also their corresponding potential differences say v1v2 ,v2v3......assigned.
how do I delete/purge all these variable(s) efficiently for my next circuit run. cos this time the circuit has only 5 nodes.
Find all posts by this user
Quote this message in a reply
11-22-2016, 12:04 AM
Post: #6
RE: Dynamic Variable(s)....Help??
(11-21-2016 11:31 PM)toshk Wrote:  now I have all these dynamic variables....
efficient way to delete them or purge them when not needed....help?? efficient app function.
Have you tried using the same way as for their creation?

Code:
#cas
dumberp() //purging 10 dummy variables of f and vnvn
BEGIN
local k, ss;
FOR k FROM 1 TO 10 DO
ss:=left(STRING(k),10); 
expr("purge(f" +ss +")"); //purge dummy f1,f2....f10
expr("purge(v" +ss +v + ss +")"); //purge dummy v1v1, v2v2....v10v10
END;
END;
#end
]
Find all posts by this user
Quote this message in a reply
11-22-2016, 04:28 PM
Post: #7
RE: Dynamic Variable(s)....Help??
(11-22-2016 12:04 AM)Didier Lachieze Wrote:  
(11-21-2016 11:31 PM)toshk Wrote:  now I have all these dynamic variables....
efficient way to delete them or purge them when not needed....help?? efficient app function.
Have you tried using the same way as for their creation?

Code:
#cas
dumberp() //purging 10 dummy variables of f and vnvn
BEGIN
local k, ss;
FOR k FROM 1 TO 10 DO
ss:=left(STRING(k),10); 
expr("purge(f" +ss +")"); //purge dummy f1,f2....f10
expr("purge(v" +ss +v + ss +")"); //purge dummy v1v1, v2v2....v10v10
END;
END;
#end
]
....it seems to dump [DOM_SYMBOLIC] in all the variables.
Find all posts by this user
Quote this message in a reply
11-22-2016, 04:50 PM
Post: #8
RE: Dynamic Variable(s)....Help??
When I execute dumber in Home it creates the CAS variables f1..f10, v1v1..v10v10.
Then if I execute dumberp in Home, it purges all these CAS variables.
Find all posts by this user
Quote this message in a reply
11-22-2016, 05:07 PM
Post: #9
RE: Dynamic Variable(s)....Help??
(11-22-2016 04:50 PM)Didier Lachieze Wrote:  When I execute dumber in Home it creates the CAS variables f1..f10, v1v1..v10v10.
Then if I execute dumberp in Home, it purges all these CAS variables.
in Home dumberp() is seems to delete the variable(s) completely....that's great! but with program error.
in Home dumber() works too ...but with the same program error too.
Find all posts by this user
Quote this message in a reply
11-22-2016, 05:54 PM
Post: #10
RE: Dynamic Variable(s)....Help??
(11-22-2016 12:04 AM)Didier Lachieze Wrote:  expr("purge(f" +ss +")"); //purge dummy f1,f2....f10
Nice to see what expr can do!
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)