pcode does not run in matlab command line mode

Hi there,
I have an issue about p file generated by the pcode. We have source control rules so I need to compile the source code to pcode. Here is the funny thing.
if I run
-------------------------------------------
/apps/matlab/bin/matlab < runModel.m
-------------------------------------------
it works. If I run
-------------------------------------------
/apps/matlab/bin/matlab < runModel.p
-------------------------------------------
It gives me an error
-------------------------------------------
>> ??? v00.00v00.00
|
Error: Unexpected MATLAB expression.
>> >> ??? ÀµZßµ
|
Error: The input character is not valid in MATLAB statements or expressions.
-------------------------------------------
Here it gets funnier, If i run matlab first then run p file
-------------------------------------------
>> bash-3.2$ /apps/matlab/bin/matlab
Warning: No display specified. You will not be able to display graphics on the screen.
< M A T L A B (R) >
Copyright 1984-2009 The MathWorks, Inc.
Version 7.9.0.529 (R2009b) 64-bit (sol64)
August 12, 2009
To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.
>> runModel.p
Name: Scenario1
-----------------------------------------------
Congratulations, that worked! but i cant ask a sales guy to run matlab and exec some code in unix!!!!!

回答 (1 件)

Walter Roberson
Walter Roberson 2013 年 11 月 29 日

0 投票

/apps/matlab/bin/matlab -r "try runModel; catch ME; end; quit"
The "<" operator in Unix is redirecting from an input file, almost as if what was in the input file was typed in response to command prompts. That can work for source code in text form, that that cannot work for .p files as those are not in source code format.

3 件のコメント

Jinghua Cao
Jinghua Cao 2013 年 11 月 29 日
thanks for that explanation. that is awesome. so simple, and so clear.
so what can i do if i want to run a p file from command line? do I have to compile it to a standalone binary file?
Jan
Jan 2013 年 11 月 29 日
The shown code works for a P-file already, so I do not understand your question in this comment.
Walter Roberson
Walter Roberson 2013 年 11 月 29 日
Just give the name without the extension. .p files have priority over .m files with the same name.

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

カテゴリ

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

質問済み:

2013 年 11 月 28 日

コメント済み:

2013 年 11 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by