compiled app can not run mfiles in a folder

1 回表示 (過去 30 日間)
farzad
farzad 2020 年 4 月 2 日
編集済み: farzad 2020 年 4 月 4 日
Hi Al
Due to app designer limitations with saving a figure (version 2017b). I came up with the idea to write the savefig command in an mfile via app(create the mfile via my application) and save that mfile in my desired directory and run it via my app ( actually with matlab) by calling it from my application.
this was working untill I had my app open in MATLAB and not compiled because it was actually MATLAB who was running that mfile. Now after compiling, I noticed this trick does not work ! Any advices ? I have tried the other tricks like creating invisible fig un UIaxes but it did not work. at least for me
I do this in my app :
txt=['saveas(f,filename,''jpg'')'];
% edit file.m
FID=fopen('filem.txt','w');
fprintf(FID, '%s', txt);
fclose(FID);
% Rename File to Create M File
movefile('filem.txt','filem.m', 'f')
filem
I am not sure if doing so would solve the problem :
run('filem.m')
  3 件のコメント
Mohammad Sami
Mohammad Sami 2020 年 4 月 2 日
farzad
farzad 2020 年 4 月 2 日
f is :
f = figure('visible', 'off');
I have tried another answer where it was suggeting to use hidden UIAXES and it did not work. are you sure the above answer will work after compiliing ?
I have a UIAxes panel in my app but it's for another purpose. will these two interfere ?I have also rainflow function to save

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

採用された回答

Walter Roberson
Walter Roberson 2020 年 4 月 2 日
You will never be able to generate a function or a script inside a compiled app and run it inside the compiled app.
Never
This is a deliberate design decision. You are permitted to compile code and run it without a MATLAB license under the restriction that the code to be executed cannot be changed. If you need the code to be executed to be changed, then you need a full MATLAB license to run it.
  25 件のコメント
Adam Danz
Adam Danz 2020 年 4 月 3 日
As you found, figure('visible', 'off') is the reason you couldn't see the figure. This problem has nothing to do with UIAxes; it has nothing to do with copying axes. A mini lesson to be learned here is to take time to understand the problem before trying random solutions.
"If I had only one hour to save the world, I would spend fifty-five minutes defining the problem, and only five minutes finding the solution." -Albert Einstein
First, get rid of the copyUIAxes stuff... it's completely irrelevant.
Second, to save your figure, use your figure handle, f:
savefig(f,'myFigure.fig')
farzad
farzad 2020 年 4 月 4 日
thank you very much it worked fine !

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSubplots についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by