run a program multiple times and report result

How to run a MATLAB program multiple times and write outputs to a text file?can we do this in matlab in windows environment? Please help ....... Thanking You, Sita

2 件のコメント

Jan
Jan 2012 年 1 月 23 日
Please decide, if you want to run a C-program, like in the header, *or* a Matlab program, like in the body of the question.
sita
sita 2012 年 1 月 24 日
sorry for the confusion in question i would like to run Matlab program

サインインしてコメントする。

 採用された回答

Jan
Jan 2012 年 1 月 24 日

1 投票

You do not have to restart Matlab to run a Matlab program. It is much faster to do this in a loop inside Matlab.
diary('D:\Temp\Result.txt');
for i = 1:10000
callYourFunction()
end
diary('off');
Of course you can use other methods than diary to create the log file, e.g.:
Str = evalc('callYourFunction')
and append the string Str to a text file. There are more possibilities, but currently the problem description is not clear enough to decide for a solution.

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 1 月 23 日

0 投票

matlab -r YourFunctionName > OutputFileName

4 件のコメント

sita
sita 2012 年 1 月 23 日
Thanks for your answer, i couldn't get it how it can be used to run program for multiple times. please provide me with an example.
Walter Roberson
Walter Roberson 2012 年 1 月 23 日
You put the command in a loop, possibly passing arguments to the command. For example,
matlab -r "YourFunction(%NUM%); quit" > OUT%NUM%.txt
(I do not have much experience in Windows BAT files so the above is not intended to be exact syntax.)
sita
sita 2012 年 1 月 24 日
i tried this command .It is not working as it is.Please help in this regards.I need to run my code for thousands runs to check for some statistical results..
Thanking You,
Sita
Walter Roberson
Walter Roberson 2012 年 1 月 24 日
Sorry, as I indicated, I do not have much experience with Windows BAT files. At home I am running all Mac, and at work I only have access to Linux systems.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeEntering Commands についてさらに検索

製品

タグ

タグが未入力です。

質問済み:

2012 年 1 月 23 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by