필터 지우기
필터 지우기

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 CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by