App-designer Writecell problem

1 Ansicht (letzte 30 Tage)
MartinM
MartinM am 19 Dez. 2019
Kommentiert: Mohammad Sami am 2 Jan. 2020
Dear all
I am creating a app-designer-program that generates a "double"-table with the resolution of equation, plots are generated also. On the top of this table I add String to identify the column, my "double-table became a "cell"-table. And I want to save it in a TXT file with writecell(...).
When I am in the developper window it's working and that's save my txt-file.
But when i Package the app, and install it in my computer, or collegue computer, the programm run and find the data to plot. But the file is not saved, and i hear a sound that's mean "problem".
But I can't solve it because on the app-design tool it's working...
Any idea?
A most "classic" GUI could be better?
Regards :)
I add the function for the app-code :
classdef BETA < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
RadiusmEditFieldLabel matlab.ui.control.Label
Rc matlab.ui.control.NumericEditField
ThicknessnmEditFieldLabel matlab.ui.control.Label
T matlab.ui.control.NumericEditField
LambdastartnmEditFieldLabel matlab.ui.control.Label
L_start matlab.ui.control.NumericEditField
LambdastopnmEditFieldLabel matlab.ui.control.Label
L_stop matlab.ui.control.NumericEditField
NumberofpointLabel matlab.ui.control.Label
nbr matlab.ui.control.NumericEditField
GasListBoxLabel matlab.ui.control.Label
gas matlab.ui.control.ListBox
PressurebarEditFieldLabel matlab.ui.control.Label
P matlab.ui.control.NumericEditField
RUN matlab.ui.control.Button
GVD matlab.ui.control.UIAxes
TOD matlab.ui.control.UIAxes
SAVE matlab.ui.control.CheckBox
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: RUN
function RUNButtonPushed(app, event)
a=2.405*2.405;
c=3e8;
rc=app.Rc.Value.*1e-6; %en m
t=app.T.Value.*1e-9;% en m
n_g=1.45;
Pression_bar=app.P.Value;
Pression_Pa=Pression_bar*1e5; %%%%% (Pa) %%%%%%%
Pression_atm=101325;
pgas=Pression_bar *1e5;
nbr=app.nbr.Value;
L_start=app.L_start.Value ;
L_stop= app.L_stop.Value ;
gas=app.gas.Value
[n22,A1,A2,B1,B2,C1,C2] = neff(L_start,L_stop,Pression_bar,nbr,gas);
lamb=linspace(L_start,L_stop,nbr).*1e-9;
[nef] = nef_calc(A1,A2,B1,B2,C1,C2,lamb,pgas,rc,t);
[beta2] = beta2_calc(A1,A2,B1,B2,C1,C2,lamb,pgas,rc,t);
[beta3] = beta3_calc(A1,A2,B1,B2,C1,C2,lamb,pgas,rc,t); ;
GVD=beta2;
TOD=beta3;
NEFF=nef;
plot(app.GVD,lamb*1e9,GVD.*1e30)
app.GVD.YLim=([-5000 5000])
app.GVD.XLim=([L_start L_stop])
title(app.GVD,'GVD (fs²/m)','Color',[0.90,0.90,0.90])
plot(app.TOD,lamb*1e9,TOD.*1e45)
app.TOD.YLim=([0 5000])
title(app.TOD,'TOD (fs^{3}/m)','Color',[0.90,0.90,0.90])
ALLDATA(:,1)=lamb.*1e9;
ALLDATA(:,2)=NEFF;
ALLDATA(:,3)=GVD.*1e30;
ALLDATA(:,4)=TOD.*1e45;
text= {'Lambda (nm)','Neff','GVD (fs²/m)','TOD (fs^{3}/m'};
% ALLDATA2=[text ; num2cell(ALLDATA)];
ALLDATA2=[ text; num2cell(ALLDATA)];
% Filename=datestr(now,'mmmm-dd-yyyy HH-MM');
Filename= ['R=' num2str(app.Rc.Value) 'µm-t=' num2str(app.T.Value) 'nm-' num2str(app.P.Value) 'bar-' gas ];
[file,path,indx]=uiputfile('.txt')
if isequal(file, '.txt') ==1
writecell(ALLDATA2, [path Filename '.txt'])
else
writecell(ALLDATA2, [path file ])
end
end
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create UIFigure and hide until all components are created
app.UIFigure = uifigure('Visible', 'off');
app.UIFigure.Color = [0.149 0.149 0.149];
app.UIFigure.Position = [50 50 1000 680];
app.UIFigure.Name = 'UI Figure';
% Create RadiusmEditFieldLabel
app.RadiusmEditFieldLabel = uilabel(app.UIFigure);
app.RadiusmEditFieldLabel.HorizontalAlignment = 'right';
app.RadiusmEditFieldLabel.FontSize = 16;
app.RadiusmEditFieldLabel.FontWeight = 'bold';
app.RadiusmEditFieldLabel.FontColor = [0.8 0.8 0.8];
app.RadiusmEditFieldLabel.Position = [44 585 99 22];
app.RadiusmEditFieldLabel.Text = 'Radius (µm)';
% Create Rc
app.Rc = uieditfield(app.UIFigure, 'numeric');
app.Rc.FontSize = 16;
app.Rc.FontWeight = 'bold';
app.Rc.FontColor = [0.149 0.149 0.149];
app.Rc.BackgroundColor = [0.902 0.902 0.902];
app.Rc.Position = [194 585 54 22];
app.Rc.Value = 30;
% Create ThicknessnmEditFieldLabel
app.ThicknessnmEditFieldLabel = uilabel(app.UIFigure);
app.ThicknessnmEditFieldLabel.HorizontalAlignment = 'right';
app.ThicknessnmEditFieldLabel.FontSize = 16;
app.ThicknessnmEditFieldLabel.FontWeight = 'bold';
app.ThicknessnmEditFieldLabel.FontColor = [0.8 0.8 0.8];
app.ThicknessnmEditFieldLabel.Position = [44 550 123 22];
app.ThicknessnmEditFieldLabel.Text = 'Thickness (nm)';
% Create T
app.T = uieditfield(app.UIFigure, 'numeric');
app.T.FontSize = 16;
app.T.FontWeight = 'bold';
app.T.FontColor = [0.149 0.149 0.149];
app.T.BackgroundColor = [0.902 0.902 0.902];
app.T.Position = [194 550 54 22];
app.T.Value = 680;
% Create LambdastartnmEditFieldLabel
app.LambdastartnmEditFieldLabel = uilabel(app.UIFigure);
app.LambdastartnmEditFieldLabel.HorizontalAlignment = 'right';
app.LambdastartnmEditFieldLabel.FontSize = 16;
app.LambdastartnmEditFieldLabel.FontWeight = 'bold';
app.LambdastartnmEditFieldLabel.FontColor = [0.8 0.8 0.8];
app.LambdastartnmEditFieldLabel.Position = [44 515 145 22];
app.LambdastartnmEditFieldLabel.Text = 'Lambda start (nm)';
% Create L_start
app.L_start = uieditfield(app.UIFigure, 'numeric');
app.L_start.FontSize = 16;
app.L_start.FontWeight = 'bold';
app.L_start.FontColor = [0.149 0.149 0.149];
app.L_start.BackgroundColor = [0.902 0.902 0.902];
app.L_start.Position = [194 515 54 22];
app.L_start.Value = 800;
% Create LambdastopnmEditFieldLabel
app.LambdastopnmEditFieldLabel = uilabel(app.UIFigure);
app.LambdastopnmEditFieldLabel.HorizontalAlignment = 'right';
app.LambdastopnmEditFieldLabel.FontSize = 16;
app.LambdastopnmEditFieldLabel.FontWeight = 'bold';
app.LambdastopnmEditFieldLabel.FontColor = [0.8 0.8 0.8];
app.LambdastopnmEditFieldLabel.Position = [44 480 144 22];
app.LambdastopnmEditFieldLabel.Text = 'Lambda stop (nm)';
% Create L_stop
app.L_stop = uieditfield(app.UIFigure, 'numeric');
app.L_stop.FontSize = 16;
app.L_stop.FontWeight = 'bold';
app.L_stop.FontColor = [0.149 0.149 0.149];
app.L_stop.BackgroundColor = [0.902 0.902 0.902];
app.L_stop.Position = [194 480 54 22];
app.L_stop.Value = 1200;
% Create NumberofpointLabel
app.NumberofpointLabel = uilabel(app.UIFigure);
app.NumberofpointLabel.HorizontalAlignment = 'right';
app.NumberofpointLabel.FontSize = 16;
app.NumberofpointLabel.FontWeight = 'bold';
app.NumberofpointLabel.FontColor = [0.8 0.8 0.8];
app.NumberofpointLabel.Position = [44 439 130 22];
app.NumberofpointLabel.Text = 'Number of point';
% Create nbr
app.nbr = uieditfield(app.UIFigure, 'numeric');
app.nbr.FontSize = 16;
app.nbr.FontWeight = 'bold';
app.nbr.FontColor = [0.149 0.149 0.149];
app.nbr.BackgroundColor = [0.902 0.902 0.902];
app.nbr.Position = [194 439 54 22];
app.nbr.Value = 20;
% Create GasListBoxLabel
app.GasListBoxLabel = uilabel(app.UIFigure);
app.GasListBoxLabel.HorizontalAlignment = 'right';
app.GasListBoxLabel.FontSize = 16;
app.GasListBoxLabel.FontWeight = 'bold';
app.GasListBoxLabel.FontColor = [0.651 0.651 0.651];
app.GasListBoxLabel.Position = [51 318 36 22];
app.GasListBoxLabel.Text = 'Gas';
% Create gas
app.gas = uilistbox(app.UIFigure);
app.gas.Items = {'Air', 'Argon', 'Xenon'};
app.gas.FontSize = 16;
app.gas.FontWeight = 'bold';
app.gas.FontColor = [0.149 0.149 0.149];
app.gas.BackgroundColor = [0.902 0.902 0.902];
app.gas.Position = [102 268 100 74];
app.gas.Value = 'Air';
% Create PressurebarEditFieldLabel
app.PressurebarEditFieldLabel = uilabel(app.UIFigure);
app.PressurebarEditFieldLabel.HorizontalAlignment = 'right';
app.PressurebarEditFieldLabel.FontSize = 16;
app.PressurebarEditFieldLabel.FontWeight = 'bold';
app.PressurebarEditFieldLabel.FontColor = [0.651 0.651 0.651];
app.PressurebarEditFieldLabel.Position = [51 224 114 22];
app.PressurebarEditFieldLabel.Text = 'Pressure (bar)';
% Create P
app.P = uieditfield(app.UIFigure, 'numeric');
app.P.FontSize = 16;
app.P.FontWeight = 'bold';
app.P.FontColor = [0.149 0.149 0.149];
app.P.BackgroundColor = [0.902 0.902 0.902];
app.P.Position = [180 224 63 22];
app.P.Value = 1;
% Create RUN
app.RUN = uibutton(app.UIFigure, 'push');
app.RUN.ButtonPushedFcn = createCallbackFcn(app, @RUNButtonPushed, true);
app.RUN.BackgroundColor = [0.902 0.902 0.902];
app.RUN.FontColor = [0.149 0.149 0.149];
app.RUN.Position = [97 130 99 22];
app.RUN.Text = 'RUN';
% Create GVD
app.GVD = uiaxes(app.UIFigure);
title(app.GVD, 'GVD (fs²/m)')
xlabel(app.GVD, 'Wavelength (nm)')
ylabel(app.GVD, 'GVD (fs²/m)')
app.GVD.PlotBoxAspectRatio = [1.94972067039106 1 1];
app.GVD.FontSize = 16;
app.GVD.XColor = [0.902 0.902 0.902];
app.GVD.YColor = [0.902 0.902 0.902];
app.GVD.ZColor = [0.902 0.902 0.902];
app.GVD.LineWidth = 1;
app.GVD.Color = [0.902 0.902 0.902];
app.GVD.BackgroundColor = [0.149 0.149 0.149];
app.GVD.Position = [323 354 678 300];
% Create TOD
app.TOD = uiaxes(app.UIFigure);
title(app.TOD, 'TOD fs3/m)')
xlabel(app.TOD, 'Wavelength (nm)')
ylabel(app.TOD, 'TOD (fs3/m)')
app.TOD.PlotBoxAspectRatio = [1.94972067039106 1 1];
app.TOD.FontSize = 16;
app.TOD.XColor = [0.902 0.902 0.902];
app.TOD.YColor = [0.902 0.902 0.902];
app.TOD.ZColor = [0.902 0.902 0.902];
app.TOD.Color = [0.902 0.902 0.902];
app.TOD.BackgroundColor = [0.149 0.149 0.149];
app.TOD.Position = [323 42 678 300];
% Create SAVE
app.SAVE = uicheckbox(app.UIFigure);
app.SAVE.Text = 'SAVE';
app.SAVE.FontSize = 16;
app.SAVE.FontWeight = 'bold';
app.SAVE.FontColor = [0.651 0.651 0.651];
app.SAVE.Position = [97 151 112 44];
% Show the figure after all components are created
app.UIFigure.Visible = 'on';
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = BETA
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
end
  2 Kommentare
Rik
Rik am 19 Dez. 2019
(rescued from spam filter)
Mohammad Sami
Mohammad Sami am 2 Jan. 2020
Try using fullfile function when merging the path and filenames.
You can also enable logging when compiling your program, which will create a log file of any errors.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by