Deployed applications - Display from within a parfor loop and some other questions
Ältere Kommentare anzeigen
Dear readers,
I have a number of questions regarding the Matlab program I am trying to deploy as a standalone Windows application. The program uses a single (but crucial) 'parfor' loop. (I should point out that the same code using just the simple 'for' loop works as intended.)
1.) From within the parfor loop, I am trying to display some information for the user. At the moment I am using the 'disp' function, e.g.:
parfor i = 1:10
...
disp(['The index of this iteration is: ', num2str(i)])
...
end
This block of code works as intended when I run it from within Matlab. However, when I compile the application and try to run it from Command Prompt, the program doesn't display the required data anymore. What seems to be the problem? Are there any other functions that could help me achieve the required result (i.e. displaying lines of text for the user)?
2.) For a number of variables, Code Analyzer gives me the following error (the program still works, but the variables are underlined in red):
"The temporary variable 'x' uses a value set outside of the PARFOR loop."
I know that for declaring the variable 'x', I am combining some data defined before the parfor loop and some data from within the loop (typically the iteration index). But what seems to be the problem?
3.) When building the deployed .exe file, I get the following warnings:
"The temporary variable 'y' will be cleared at the beginning of each
iteration of the parfor loop. Any value assigned to it before the loop will be lost."
I am well aware of this and it is OK with me, however, I don't know how to disable the warning. I tried using the warning('off, 'all'), but the warnings persist. What especially bothers me is the fact that these warnings are also displayed each time that I run the deployed application from Command Prompt.
4.) As a final question, I noticed that there is a huge difference in file size of the deployed application when I'm using the parfor loop compared to the case when I'm instead using a simple for loop. The application with the parfor loop is well over 8 MB in size, whereas the application with the for loop is only 400 kB. I guess that trying to compile the code for using parallel processing takes many more lines, but I'm interested in hearing more about this.
Thank you very much in advance for all the help!
5 Kommentare
Richard Alcock
am 14 Jan. 2013
Which version of MATLAB are you using?
Lipa
am 15 Jan. 2013
Richard Alcock
am 15 Jan. 2013
Thanks. Any chance you could also post a short piece of code that demonstrates the messages you talk about in 2) and 3)? Would help in giving useful advice.
Lipa
am 15 Jan. 2013
Richard Alcock
am 15 Jan. 2013
I don't see those messages from those pieces of code either. I suspect there are other places in the large program that refer to some of the same variables as these smaller snippets, and it is these other uses that are causing the problem. My advice would be to break up the larger program into several smaller functions, where each function only has the variables it needs. This will at least make it easier to isolate the problems, and might make things completely clean.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Parallel for-Loops (parfor) finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!