compiler 'attempt to run script as function'

I'm trying to call a few instances of Matlab code using Matlab compiler. I'm calling fom the shell, and using the process ID as an index to run different operations, so my compiled code is something like this:
function myFunction(num)
% do something
return
However, I keep getting the error, "Attempt to execute SCRIPT as a function"
According to what I've seen, this should meet the definition of a function. It it something to do with the compiler? If so, how can I get this to work? Help please!!

4 件のコメント

Walter Roberson
Walter Roberson 2021 年 11 月 19 日
Try "clear" and the function name if it was a script before in the same session.
Yongjian Feng
Yongjian Feng 2021 年 11 月 19 日
Also try:
which myFunction
This will tell you what matlab thinks myFunction should be
Renee
Renee 2021 年 11 月 19 日
編集済み: Renee 2021 年 11 月 19 日
Re: "clear"
I tried that, same error. The error is coming from when I run the compiled code, in case that's not clear. If I call it in Matlab console, it works fine.
Re: "which"
It gives me
~path/myFunction.m
Not sure what that means
Renee
Renee 2021 年 11 月 20 日
I figured it out - I had another file of the same name in another folder, it was causing the issue apparently. Thank you!

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

回答 (0 件)

カテゴリ

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

製品

リリース

R2019b

質問済み:

2021 年 11 月 19 日

コメント済み:

2021 年 11 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by