Dear all,
I have a simulink model which references another model inside. I have a list of variables for the referenced model. I would like to run the simulation using parfor loop in different workers. I have been trying to assign these variables in different workers using 1.assignin commands, 2.trying to run the M File containing these variables and also 3.trying to load the .mat file, but nothing seems to be working. I receive an error while building the referenced model. I have realized that the variables are not received by the workers.
I am also using the accelerator mode.
I would really appreciate if anyone could pls help me find a solution on how to assign the variables in different workers for the referenced model ??
Thanks in advance
Sumant
|
|
0
|
|
|
|
Reply
|
Sumant
|
1/22/2010 10:10:23 PM |
|
"Sumant " <stal_yaji2002@yahoo.co.in> wrote in message <hjd7of$hh4$1@fred.mathworks.com>...
> Dear all,
>
> I have a simulink model which references another model inside. I have a list of variables for the referenced model. I would like to run the simulation using parfor loop in different workers. I have been trying to assign these variables in different workers using 1.assignin commands, 2.trying to run the M File containing these variables and also 3.trying to load the .mat file, but nothing seems to be working.
========================
Try inserting explicit pre-declarations of the variables before you use assign/load or whatever
var1=[]; var2=[];, var3=[]; etc...
assginin(...)
assignin(...)
Not doing so is a known hazard of assignin,load,evalin, and others...
|
|
0
|
|
|
|
Reply
|
Matt
|
1/22/2010 10:35:23 PM
|
|
Thanks, But I wanted to know, what if i have say some 100 variables in one reference model and 100 in another... do i have to assign each variable using this assignin command...??
or
I wanted to know if there is any other simpler way of assigning the variables.. say in one single file or..??
Thanks once again
Sumant
"Matt J " <mattjacREMOVE@THISieee.spam> wrote in message <hjd97b$mad$1@fred.mathworks.com>...
> "Sumant " <stal_yaji2002@yahoo.co.in> wrote in message <hjd7of$hh4$1@fred.mathworks.com>...
> > Dear all,
> >
> > I have a simulink model which references another model inside. I have a list of variables for the referenced model. I would like to run the simulation using parfor loop in different workers. I have been trying to assign these variables in different workers using 1.assignin commands, 2.trying to run the M File containing these variables and also 3.trying to load the .mat file, but nothing seems to be working.
> ========================
>
> Try inserting explicit pre-declarations of the variables before you use assign/load or whatever
>
> var1=[]; var2=[];, var3=[]; etc...
>
> assginin(...)
> assignin(...)
>
> Not doing so is a known hazard of assignin,load,evalin, and others...
|
|
0
|
|
|
|
Reply
|
Sumant
|
1/23/2010 12:55:25 AM
|
|
"Sumant " <stal_yaji2002@yahoo.co.in> wrote in message <hjdhdt$qgc$1@fred.mathworks.com>...
> Thanks,
=============
So, that fixed the problem?
>But I wanted to know, what if i have say some 100 variables in one reference model and 100 in another... do i have to assign each variable using this assignin command...??
> or
> I wanted to know if there is any other simpler way of assigning the variables.. say in one single file or..??
=================
Not sure I understand.
It is always dangerous to introduce a variable into a workspace without an explicit assignment statement (a practice called "poofing" by some).
If you have hundreds of variables, it would probably be helpful for you to hold them all as fields in a structure
S.var1, S.var2, etc...
Note that if you have all the variables stored in a .mat file, you can assign them to structure fields via the syntax
S=load(FileName)
This avoids the poofing problem because S is introduced into the workspace through an explicitly assignment statement, S=..... If you find it inconvenient to access your variables through dot indexing syntax S.var1, S.var2, etc... you can unpack the structure S using my structvars() tool:
http://www.mathworks.com/matlabcentral/fileexchange/26216-structure-fields-to-variables
|
|
0
|
|
|
|
Reply
|
Matt
|
1/23/2010 1:14:09 AM
|
|
Hi,
The problem is fixed, as you have mentioned we cant assign the variables to the workspace without an explicit assign statement. So what I am working on is saving the variables in a MAT-File and the loading the file in the Workspace with an assign statement. It seems to be working.
Thanks once again for your advice
Regards
Sumant
"Matt J " <mattjacREMOVE@THISieee.spam> wrote in message <hjdih1$386$1@fred.mathworks.com>...
> "Sumant " <stal_yaji2002@yahoo.co.in> wrote in message <hjdhdt$qgc$1@fred.mathworks.com>...
>
> > Thanks,
> =============
>
> So, that fixed the problem?
>
>
> >But I wanted to know, what if i have say some 100 variables in one reference model and 100 in another... do i have to assign each variable using this assignin command...??
> > or
> > I wanted to know if there is any other simpler way of assigning the variables.. say in one single file or..??
> =================
>
> Not sure I understand.
>
> It is always dangerous to introduce a variable into a workspace without an explicit assignment statement (a practice called "poofing" by some).
>
> If you have hundreds of variables, it would probably be helpful for you to hold them all as fields in a structure
>
> S.var1, S.var2, etc...
>
> Note that if you have all the variables stored in a .mat file, you can assign them to structure fields via the syntax
>
> S=load(FileName)
>
> This avoids the poofing problem because S is introduced into the workspace through an explicitly assignment statement, S=..... If you find it inconvenient to access your variables through dot indexing syntax S.var1, S.var2, etc... you can unpack the structure S using my structvars() tool:
>
> http://www.mathworks.com/matlabcentral/fileexchange/26216-structure-fields-to-variables
|
|
0
|
|
|
|
Reply
|
Sumant
|
1/25/2010 8:54:02 AM
|
|
|
4 Replies
402 Views
(page loaded in 0.044 seconds)
Similiar Articles: Assigning Variables in a parfor loop - comp.soft-sys.matlab ...Dear all, I have a simulink model which references another model inside. I have a list of variables for the referenced model. I would like to run t... Another PARFOR reduction variable headache - comp.soft-sys.matlab ...... by a message of the type "Error: The variable A in a parfor ... Is there any way this can be done in a parfor loop? ... to do just the computation inside the PARFOR and assign ... need to kill worker process in parfor loop - comp.soft-sys.matlab ...... indicates that the corresponding output should not be assigned to a variable in ... doing this another way, I need to know if the individual iterates in the parfor loop ... parfor with sedumi or yalmip - comp.soft-sys.matlabFor instance, I can't even define a Yalmip variable inside a parfor loop. The code works fine with a for loop and the parfor loop cannot understand "sdpvar". How to get matrix output by using parfor loop - comp.soft-sys ...Would you please help me to figure out how to get a matrix output by using parfor loop. ... rows from a matrix - comp.soft-sys.matlab ... Then you can use the loop variable as ... Create Loops and variables dynamically - comp.soft-sys.sas ...You could also consider replacing "spmd(4)" with a PARFOR loop, as this ... creating for loop and variable dynamically VB.NET How to create for loop & variable ... For loops in BASIC - comp.sys.apple2.programmerSo I can use one loop in the code to count for all the variables in array I(x)? ... counter variable, say IX, and then (if necessary) re-assigning it ... performance array of struct vs. multiple arrays - comp.soft-sys ...At the moment the code runs in a PARFOR loop, so each worker gets it's chunk depending ... of struct vs. multiple arrays - comp.soft-sys ..... com) you can store GPU variables ... Creating Variables thru loop or ? - comp.soft-sys.matlab ...Learn to use cell arrays, so you can assign all of these "variables" into one single cell ... Creating Variables thru loop or ? - comp.soft-sys.matlab ... Using Variables in ... Initializing ksh variables - comp.unix.solarisWhile loop in tcsh - comp.unix.shell error while executing ksh script ... PS1='$ ' More ... The next two examples show initializing and assigning values to two new variables: Assigning Variables in a parfor loop - comp.soft-sys.matlab ...Dear all, I have a simulink model which references another model inside. I have a list of variables for the referenced model. I would like to run t... Assigning Variables in a parfor loop - Newsreader - MATLAB CentralFile exchange, MATLAB Answers, newsgroup access, Links, and Blogs for the MATLAB & Simulink user community 7/21/2012 4:28:09 AM
|