help with dynamic rename (and run) of m-file

2 ビュー (過去 30 日間)
Brantosaurus
Brantosaurus 2022 年 11 月 13 日
コメント済み: Brantosaurus 2022 年 11 月 13 日
I have two self contained files, one i need to call several times from a script. It is named deck.m and takes the form x=ABC(loads of input arguments). Associated with it is a p-file, ABC.p.
I simply call it in the script as below and things work fine.
script
deck
script
deck
:
Unfortunately the deck name often changes. Is there a dynamic way of renaming (and running) it in the script?
Something like:
name = 'deck' (thinks its a variable!) = deck (attempt to execute script as a function!)
script
name
script
name.
No luck so far :(
  2 件のコメント
Christopher Stapels
Christopher Stapels 2022 年 11 月 13 日
Are you doing this in ThingSpeak? I dont think you can save files in ThingSpeak, so I suspect not. But I see you added the tag "ThingSpeak" to this post
Brantosaurus
Brantosaurus 2022 年 11 月 13 日
MATLAB, sorry i must have forgot to indicate this

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

採用された回答

Walter Roberson
Walter Roberson 2022 年 11 月 13 日
移動済み: Walter Roberson 2022 年 11 月 13 日
is deck a script or a function with no parameters?
If it is a script see run()
If it is a function then create a function handle and invoke the handle each time
  1 件のコメント
Brantosaurus
Brantosaurus 2022 年 11 月 13 日
It looks like a function which resides in the p-file. All i can see in the deck are its input arguments.
Your suggestion for treating it as a script works though, so i am happy with that.
Thank you once again.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by