-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_exported.m
2211 lines (1915 loc) · 117 KB
/
app_exported.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
classdef app_exported < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
MagAnalystUIFigure matlab.ui.Figure
ProjectMenu matlab.ui.container.Menu
OpenMenu matlab.ui.container.Menu
SaveMenu matlab.ui.container.Menu
SaveasMenu matlab.ui.container.Menu
AppGridLayout matlab.ui.container.GridLayout
MessagesTabPanel matlab.ui.container.TabGroup
MessagesTab matlab.ui.container.Tab
MessagesGridLayout matlab.ui.container.GridLayout
MessagesTextArea matlab.ui.control.TextArea
TabGroup matlab.ui.container.TabGroup
MagnetizationinputdataTab matlab.ui.container.Tab
GridLayoutMagnetizationInputData matlab.ui.container.GridLayout
GridLayoutInputPlot matlab.ui.container.GridLayout
GridLayoutInputPlots matlab.ui.container.GridLayout
AxesRawInputData matlab.ui.control.UIAxes
AxesProcessedInputData matlab.ui.control.UIAxes
GridLayoutInputTipsAndPlotButton matlab.ui.container.GridLayout
GridLayoutInputPlotButton matlab.ui.container.GridLayout
GridLayoutTips matlab.ui.container.GridLayout
MTipField matlab.ui.control.EditField
MtipAmLabel matlab.ui.control.Label
HTipField matlab.ui.control.EditField
HtipAmLabel matlab.ui.control.Label
GridLayoutInputPlotLog matlab.ui.container.GridLayout
logCheckBoxInputPlot matlab.ui.control.CheckBox
GridLayoutInput matlab.ui.container.GridLayout
GridLayoutDatasetPath matlab.ui.container.GridLayout
InputDatasetPath matlab.ui.control.EditField
InputBrowseButton matlab.ui.control.Button
InputDatasetpathLabel matlab.ui.control.Label
DescriptionLabel matlab.ui.control.Label
GridLayout matlab.ui.container.GridLayout
DescriptionTextArea matlab.ui.control.TextArea
GridLayoutInputCurve matlab.ui.container.GridLayout
CurveDropDown matlab.ui.control.DropDown
CurveDropDownLabel matlab.ui.control.Label
GridLayoutInputVerticalAxis matlab.ui.container.GridLayout
VerticalaxisfieldDropDown matlab.ui.control.DropDown
VerticalaxisfieldDropDownLabel matlab.ui.control.Label
GridLayoutInputHorizontalAxis matlab.ui.container.GridLayout
HorizontalaxisfieldDropDown matlab.ui.control.DropDown
HorizontalaxisfieldDropDownLabel matlab.ui.control.Label
AnhystereticmagnetizationfittingTab matlab.ui.container.Tab
AnhystereticmagnetizationfittingTabGridLayout matlab.ui.container.GridLayout
GridLayoutNumbers matlab.ui.container.GridLayout
FittedparametersLabel matlab.ui.control.Label
GridLayoutModeledCurve matlab.ui.container.GridLayout
PointSpaceDropDown matlab.ui.control.DropDown
NumberofpointsEditField matlab.ui.control.NumericEditField
NumberofpointsEditFieldLabel matlab.ui.control.Label
NumberofcomponentsSpinner matlab.ui.control.Spinner
NumberofcomponentsSpinnerLabel matlab.ui.control.Label
ModeledcurveLabel matlab.ui.control.Label
TableQuantities matlab.ui.control.Table
GridLayoutOtherQuantities matlab.ui.container.GridLayout
murinLabel matlab.ui.control.Label
murinField matlab.ui.control.EditField
JsField matlab.ui.control.EditField
JsTEditFieldLabel matlab.ui.control.Label
OthercalculatedquantitiesLabel matlab.ui.control.Label
GridLayoutButtons matlab.ui.container.GridLayout
ErrorDisplay matlab.ui.control.EditField
ErrortominimizeDropDown matlab.ui.control.DropDown
ErrortominimizeDropDownLabel matlab.ui.control.Label
CalculatePlotButton matlab.ui.control.Button
FitButton matlab.ui.control.Button
TableParameters matlab.ui.control.Table
ModelretrievedparametersLabel matlab.ui.control.Label
TableFittedParameters matlab.ui.control.Table
GridLayoutAxes matlab.ui.container.GridLayout
GridLayoutOptionsHdMdH matlab.ui.container.GridLayout
ShowgridCheckBoxHdMdH matlab.ui.control.CheckBox
PlotcomponentsCheckBoxHdMdH matlab.ui.control.CheckBox
ResidualplotButtondHdMdH matlab.ui.control.Button
logCheckBoxHdMdH matlab.ui.control.CheckBox
GridLayoutOptionsdMdH matlab.ui.container.GridLayout
ShowgridCheckBoxdMdH matlab.ui.control.CheckBox
PlotcomponentsCheckBoxdMdH matlab.ui.control.CheckBox
ResidualplotButtondMdH matlab.ui.control.Button
logCheckBoxdMdH matlab.ui.control.CheckBox
GridLayoutOptionsM matlab.ui.container.GridLayout
SetColorsButton matlab.ui.control.Button
ShowgridCheckBoxM matlab.ui.control.CheckBox
PlotcomponentsCheckBoxM matlab.ui.control.CheckBox
ResidualplotButtonM matlab.ui.control.Button
logCheckBoxM matlab.ui.control.CheckBox
AxesHdMdH matlab.ui.control.UIAxes
AxesdMdH matlab.ui.control.UIAxes
AxesM matlab.ui.control.UIAxes
MagnetizationoutputdataTab matlab.ui.container.Tab
GridLayoutMagnetizationoutputdata matlab.ui.container.GridLayout
GridLayoutExperimentalMagnetizationData matlab.ui.container.GridLayout
DropDownOutputExperimentalMagnetizationData matlab.ui.control.DropDown
EditFieldFileNameExperimentalMagnetizationData matlab.ui.control.EditField
ExperimentalanhystereticmagnetizationLabel matlab.ui.control.Label
CheckBoxExperimentalMagnetization matlab.ui.control.CheckBox
GridLayoutExportResiduesButton matlab.ui.container.GridLayout
ExportResiduesButton matlab.ui.control.Button
GridLayoutExportResiduesSemiLogMagDerivative matlab.ui.container.GridLayout
DropDownResiduesSemiLogMagDerivativeExtension matlab.ui.control.DropDown
EditFieldFileNameResiduesSemiLogMagDerivative matlab.ui.control.EditField
CheckBoxExportResiduesSemiLogMagDerivative matlab.ui.control.CheckBox
SemilogmagnetizationderivativeResiduesExportLabel matlab.ui.control.Label
GridLayoutExportResiduesSusceptibility matlab.ui.container.GridLayout
DropDownResiduesSusceptibilityExtension matlab.ui.control.DropDown
EditFieldFileNameResiduesSusceptibility matlab.ui.control.EditField
CheckBoxExportResiduesSusceptibility matlab.ui.control.CheckBox
SusceptibilityResiduesExportLabel matlab.ui.control.Label
ResidualplotsdataLabel matlab.ui.control.Label
GridLayoutExportResiduesMagnetization matlab.ui.container.GridLayout
DropDownResiduesMagnetizacionExtension matlab.ui.control.DropDown
EditFieldFileNameResiduesMagnetization matlab.ui.control.EditField
CheckBoxExportResiduesMagnetization matlab.ui.control.CheckBox
MagnetizationExportResiduesLabel matlab.ui.control.Label
GridLayoutExportPlotsButton matlab.ui.container.GridLayout
ExportPlotsButton matlab.ui.control.Button
GridLayoutExportPlotSemiLogMagDerivative matlab.ui.container.GridLayout
DropDownPlotSemiLogMagDerivativeExtension matlab.ui.control.DropDown
EditFieldFileNamePlotSemiLogMagDerivative matlab.ui.control.EditField
CheckBoxExportPlotSemiLogMagDerivative matlab.ui.control.CheckBox
SemilogmagnetizationderivativePlotExportLabel matlab.ui.control.Label
GridLayoutExportPlotSusceptibility matlab.ui.container.GridLayout
DropDownPlotSusceptibilityExtension matlab.ui.control.DropDown
EditFieldFileNamePlotSusceptibility matlab.ui.control.EditField
CheckBoxExportPlotSusceptibility matlab.ui.control.CheckBox
SusceptibilityPlotExportLabel matlab.ui.control.Label
GridLayoutExportPlotMagnetization matlab.ui.container.GridLayout
DropDownPlotMagnetizacionExtension matlab.ui.control.DropDown
EditFieldFileNamePlotMagnetization matlab.ui.control.EditField
CheckBoxExportPlotMagnetization matlab.ui.control.CheckBox
MagnetizationPlotExportLabel matlab.ui.control.Label
PlotsLabel matlab.ui.control.Label
GridLayoutExportParametersButton matlab.ui.container.GridLayout
ExportErrorsCheckBox matlab.ui.control.CheckBox
ExportOtherquantitiesCheckBox matlab.ui.control.CheckBox
ExportParametersButton matlab.ui.control.Button
GridLayoutExportParametersFile matlab.ui.container.GridLayout
ExportModelparametersCheckBox matlab.ui.control.CheckBox
ExportFittedparametersCheckBox matlab.ui.control.CheckBox
DropDownOutputParametersExtension matlab.ui.control.DropDown
EditFieldFileNameParameters matlab.ui.control.EditField
ParametersLabel matlab.ui.control.Label
GridLayoutExportData matlab.ui.container.GridLayout
ModeledanhystereticmagnetizationcomponentsLabel matlab.ui.control.Label
OutputSeparateComponentsCheckBox matlab.ui.control.CheckBox
ExportdataButton matlab.ui.control.Button
GridLayoutMagnetizationDataFittedAnhystereticMagnetization matlab.ui.container.GridLayout
DropDownOutputModeledAnhystereticMagnetizationExtension matlab.ui.control.DropDown
EditFieldFileNameModeledAnhystereticMagnetization matlab.ui.control.EditField
ModeledanhystereticmagnetizationLabel matlab.ui.control.Label
CheckBoxOutputMagnetizationDataFittedAnhystereticMagnetization matlab.ui.control.CheckBox
MagnetizationdataLabel matlab.ui.control.Label
GridLayoutOutputDatasetPath matlab.ui.container.GridLayout
OutputBrowseButton matlab.ui.control.Button
OutputDatasetPath matlab.ui.control.EditField
OutputDatasetpathLabel matlab.ui.control.Label
end
properties (Access = private)
H_raw
M_raw
data_curve
modeled_curve
Hcr
mcr
Hx
magnetic_parameters
number_components
lb
ub
select_fit
Colors
ColorDialogApp
ProjectPath
end
methods (Access = private)
function plot(app)
app.plot_M();
app.plot_dMdH();
app.plot_HdMdH();
app.init_parameters_table(false);
app.init_quantities_table(false);
offset = (3*app.number_components - 1);
for i = 1:app.number_components
app.TableFittedParameters.Data(offset + 1 + (i-1)*2) = {app.format_short(app.Hcr(i))};
app.TableFittedParameters.Data(offset + 2 + (i-1)*2) = {app.format_long(app.mcr(i))};
end
for i = 1:(app.number_components-1)
app.TableFittedParameters.Data(offset + i + 2*app.number_components) = {app.format_short(app.Hx(i))};
end
for i = 1:offset
app.TableFittedParameters.Data(2*offset + i) = {app.format_short(str2double(app.TableFittedParameters.Data(2*offset + i)))};
app.TableFittedParameters.Data(3*offset + i) = {app.format_short(str2double(app.TableFittedParameters.Data(3*offset + i)))};
end
app.JsField.Value = app.format_short(app.magnetic_parameters.Js);
app.murinField.Value = app.format_engineering(app.magnetic_parameters.murin);
if (app.ErrortominimizeDropDown.Value == "Diagonal")
error_calculator = DiagonalErrorCalculator(app.data_curve, app.modeled_curve);
end
if (app.ErrortominimizeDropDown.Value == "Vertical")
error_calculator = VerticalErrorCalculator(app.data_curve, app.modeled_curve);
end
if (app.ErrortominimizeDropDown.Value == "Horizontal")
error_calculator = HorizontalErrorCalculator(app.data_curve, app.modeled_curve);
end
e = error_calculator.get_error();
app.ErrorDisplay.Value = app.format_engineering(e);
end
function calculate_parameters(app)
N = app.NumberofpointsEditField.Value;
utils = Utils();
[HTip, ~] = utils.find_tip(app.data_curve.H, app.data_curve.M);
select_a = app.TableParameters.Data{1:app.number_components,5};
app.magnetic_parameters = MagneticParameters(app.data_curve, app.Hcr, app.mcr, app.Hx, select_a);
if(app.PointSpaceDropDown.Value == "log")
Hhat = logspace(log10(app.data_curve.H(2)),log10(HTip),N-1);
elseif(app.PointSpaceDropDown.Value == "linear")
Hhat = linspace(app.data_curve.H(2),HTip,N-1);
end
Hhat = [0, Hhat];
app.modeled_curve = ModeledAnhystereticCurve(Hhat, app.magnetic_parameters);
end
function fit_parameters(app)
app.calculate_parameters()
select_a = app.TableParameters.Data{1:app.number_components,5};
fit_lb = zeros(app.number_components*3 - 1, 1);
fit_ub = zeros(app.number_components*3 - 1, 1);
fit_select_fit = cell(app.number_components*3 - 1, 1);
for i=1:app.number_components
fit_lb(i) = app.lb(2*i - 1);
fit_lb(i + app.number_components) = app.lb(2*i);
fit_ub(i) = app.ub(2*i - 1);
fit_ub(i + app.number_components) = app.ub(2*i);
fit_select_fit(i) = app.select_fit(2*i - 1);
fit_select_fit(i + app.number_components) = app.select_fit(2*i);
end
for i=1:(app.number_components-1)
fit_lb(i + 2*app.number_components) = app.lb(2*app.number_components + i);
fit_ub(i + 2*app.number_components) = app.ub(2*app.number_components + i);
fit_select_fit(i + 2*app.number_components) = app.select_fit(2*app.number_components + i);
end
app.write_message("Fitting started");
pause(0.01);
tic
try
[app.Hcr, app.mcr, app.Hx] = fit(app.data_curve, cat(2, app.Hcr, app.mcr, app.Hx), select_a, app.ErrortominimizeDropDown.Value, fit_lb, fit_ub, fit_select_fit);
t = sprintf("%0.2f", toc);
app.write_message("Fitting finished after " + t + " s");
catch e
t = sprintf("%0.2f", toc);
app.write_message("Fitting failed after " + t + " s: " + e.message);
end
end
function update_components(app)
app.Hcr = zeros(1, app.number_components);
app.mcr = zeros(1, app.number_components);
offset = (3*app.number_components - 1);
for i = 1:app.number_components
app.Hcr(i) = str2double(app.TableFittedParameters.Data(offset + 1 + (i-1)*2));
app.mcr(i) = str2double(app.TableFittedParameters.Data(offset + 2 + (i-1)*2));
end
for i = 1:(app.number_components-1)
app.Hx(i) = str2double(app.TableFittedParameters.Data(offset + i + 2*app.number_components));
end
if (app.number_components == 1)
app.Hx = [];
end
app.lb = zeros(1, offset);
app.ub = zeros(1, offset);
app.select_fit = cell(1, offset);
for i = 1:offset
app.lb(i) = str2double(app.TableFittedParameters.Data(2*offset + i));
app.ub(i) = str2double(app.TableFittedParameters.Data(3*offset + i));
app.select_fit(i) = app.TableFittedParameters.Data(4*offset + i);
end
end
function init_components(app)
row_count = 3*app.number_components - 1;
component_values = zeros(row_count, 1);
lb_col = zeros(row_count, 1);
ub_col = zeros(row_count, 1);
row_names = cell(row_count, 1);
for i = 1:app.number_components
s = 'Hcr' + string(char(8320 + i));
row_names(2*i - 1,:) = {convertStringsToChars(s + ' [A/m]')};
component_values(2*i-1) = 0.01*i;
s = 'm' + string(char(8320 + i)) + ' (' + s + ')';
row_names(2*i,:) = {convertStringsToChars(s)};
component_values(2*i) = 0.521657107787896;
lb_col(2*i-1) = 0;
lb_col(2*i) = 0.4496;
ub_col(2*i-1) = 1000000;
ub_col(2*i) = 1;
end
for i = 1:(app.number_components-1)
s = 'Hx' + string(char(8320 + i)) + ' [A/m]';
row_names(i + 2*app.number_components,:) = {convertStringsToChars(s)};
component_values(i + 2*app.number_components) = i*0.015;
lb_col(i + 2*app.number_components) = 0;
ub_col(i + 2*app.number_components) = 1000000;
end
component_values = arrayfun(@(x) {app.format_long(x)}, component_values);
lb_col = arrayfun(@(x) {app.format_short(x)}, lb_col);
ub_col = arrayfun(@(x) {app.format_short(x)}, ub_col);
app.select_fit = cell(row_count, 1);
app.select_fit(:) = {true};
t = table(row_names, component_values, lb_col, ub_col, app.select_fit);
app.TableFittedParameters.Data = table2cell(t);
app.init_parameters_table(true);
app.init_quantities_table(true);
end
function plot_input(app)
[HTip, MTip] = Utils().find_tip(app.data_curve.H, app.data_curve.M);
app.MTipField.Value = app.format_short(MTip);
app.HTipField.Value = app.format_short(HTip);
cla(app.AxesProcessedInputData, 'reset')
cla(app.AxesRawInputData, 'reset')
plotter = Plotter(app.data_curve, app.modeled_curve, [], app.Colors, 5);
if(app.logCheckBoxInputPlot.Value == 0)
plotter.plot_raw(app.AxesProcessedInputData, app.data_curve.H, app.data_curve.M, 'H [A/m]', 'M [A/m]', 'Processed input data');
plotter.plot_raw(app.AxesRawInputData, app.H_raw, app.M_raw, app.HorizontalaxisfieldDropDown.Value, app.VerticalaxisfieldDropDown.Value, 'Raw input data');
else
plotter.plot_raw_log(app.AxesProcessedInputData, app.data_curve.H, app.data_curve.M, 'H [A/m]', 'M [A/m]', 'Processed input data');
plotter.plot_raw_log(app.AxesRawInputData, app.H_raw, app.M_raw, app.HorizontalaxisfieldDropDown.Value, app.VerticalaxisfieldDropDown.Value, 'Raw input data');
end
end
function init_parameters_table(app, default_values)
parameters_col = cell(app.number_components, 1);
for i = 1:app.number_components
s = string(i);
parameters_col(i,:) = {convertStringsToChars(s)};
end
Ms_col = cell(app.number_components, 1);
alpha_col = cell(app.number_components, 1);
a_col = cell(app.number_components, 1);
select_a_col = cell(app.number_components, 1);
for i = 1:app.number_components
select_a_col(i,:) = {'low'};
end
if ~default_values
select_a_col = app.TableParameters.Data{:,5};
for i = 1:app.number_components
Ms_col(i,:) = {app.format_short(app.magnetic_parameters.Ms(i))};
alpha_col(i,:) = {app.format_engineering(app.magnetic_parameters.alpha(i))};
a_col(i,:) = {app.format_short(app.magnetic_parameters.a(i))};
end
end
t = table(parameters_col, Ms_col, alpha_col, a_col, select_a_col);
t.(5) = categorical(t.(5), {'high', 'low'}, 'Ordinal', true);
app.TableParameters.Data = t;
end
function init_quantities_table(app, default_values)
parameters_col = cell(app.number_components, 1);
for i = 1:app.number_components
s = string(i);
parameters_col(i,:) = {convertStringsToChars(s)};
end
dimensionless_alphaMs_col = cell(app.number_components, 1);
density_product_col = cell(app.number_components, 1);
Hk_col = cell(app.number_components, 1);
initial_relative_magnetic_permeability_col = cell(app.number_components, 1);
if ~default_values
for i = 1:app.number_components
dimensionless_alphaMs_col(i,:) = {app.format_short(app.magnetic_parameters.dimensionless_alphaMs(i))};
density_product_col(i,:) = {app.format_short(app.magnetic_parameters.density_product(i))};
Hk_col(i,:) = {app.format_short(app.magnetic_parameters.Hk(i))};
% initial_relative_magnetic_permeability_col(i,:) = {app.format_thousands_only(app.magnetic_parameters.initial_relative_magnetic_permeability(i))};
initial_relative_magnetic_permeability_col(i,:) = {app.format_short(app.magnetic_parameters.initial_relative_magnetic_permeability(i))};
end
end
t = table(parameters_col, dimensionless_alphaMs_col, density_product_col, Hk_col, initial_relative_magnetic_permeability_col);
app.TableQuantities.Data = t;
end
function ret = format_short(~, v)
string_value = char(sprintf("%0.4f",v));
aux = regexp(string_value,'\.','split');
aux{1} = fliplr(regexprep(fliplr(aux{1}),'\d{3}(?=\d)', '$0,'));
ret = [aux{1},'.',aux{2}];
end
function ret = format_long(~, v)
string_value = char(sprintf("%0.10f",v));
aux = regexp(string_value,'\.','split');
aux{1} = fliplr(regexprep(fliplr(aux{1}),'\d{3}(?=\d)', '$0,'));
ret = [aux{1},'.',aux{2}];
end
function ret = format_engineering(~, v)
ret = char(sprintf("%0.4e",v));
end
function ret = format_thousands_only(~, v)
string_value = char(sprintf("%d",round(v)));
ret = fliplr(regexprep(fliplr(string_value),'\d{3}(?=\d)', '$0,'));
end
function plot_M(app)
plotter = Plotter(app.data_curve, app.modeled_curve, app.Hcr, app.Colors);
cla(app.AxesM,'reset');
plot_components = app.PlotcomponentsCheckBoxM.Value == 1;
show_grid = app.ShowgridCheckBoxM.Value == 1;
if(app.logCheckBoxM.Value == 0)
plotter.plot_M(app.AxesM, plot_components, show_grid);
else
plotter.plot_M_log(app.AxesM, plot_components, show_grid);
end
end
function plot_dMdH(app)
plotter = Plotter(app.data_curve, app.modeled_curve, app.Hcr, app.Colors);
cla(app.AxesdMdH,'reset');
plot_components = app.PlotcomponentsCheckBoxdMdH.Value == 1;
show_grid = app.ShowgridCheckBoxdMdH.Value == 1;
if(app.logCheckBoxdMdH.Value == 0)
plotter.plot_dMdH(app.AxesdMdH, plot_components, show_grid);
else
plotter.plot_dMdH_log(app.AxesdMdH, plot_components, show_grid);
end
end
function plot_HdMdH(app)
plotter = Plotter(app.data_curve, app.modeled_curve, app.Hcr, app.Colors);
cla(app.AxesHdMdH,'reset');
plot_components = app.PlotcomponentsCheckBoxHdMdH.Value == 1;
show_grid = app.ShowgridCheckBoxHdMdH.Value == 1;
if(app.logCheckBoxHdMdH.Value == 0)
plotter.plot_HdMdH(app.AxesHdMdH, plot_components, show_grid);
else
plotter.plot_HdMdH_log(app.AxesHdMdH, plot_components, show_grid);
end
end
function results = get_time_string(~)
results = string(datetime(datetime, 'Format', 'yy/MM/dd HH:mm:ss'));
end
function write_message(app, message)
msg = sprintf("[%s] %s", app.get_time_string(), message);
app.MessagesTextArea.Value(end+1) = cellstr(msg);
end
function import_data(app, path)
H_unit = app.HorizontalaxisfieldDropDown.Value;
M_unit = app.VerticalaxisfieldDropDown.Value;
curve_type = app.CurveDropDown.Value;
[H, M, app.H_raw, app.M_raw] = Parser(path, H_unit, M_unit, curve_type).import();
app.data_curve = DataAnhystereticCurve(H, M);
end
function ret = subscript_to_number(~, str)
chars = char(str);
for i = 1:length(chars)
if chars(i) >= 8272
chars(i) = 48 + chars(i) - '₀';
end
end
ret = string(chars);
end
function export_residual(app, residue, file_name)
t = table(transpose(app.data_curve.H), transpose(residue));
t.Properties.VariableNames(:) = {'H [A/m]' 'residue'};
path = strcat(app.OutputDatasetPath.Value, '\', file_name);
writetable(t,path, 'Delimiter', ';');
app.write_message("Data saved as " + file_name);
end
function save(app)
file = fopen(app.ProjectPath,'w');
s.fitted_parameters_value = app.TableFittedParameters.Data(:,2);
s.fitted_parameters_lower_bound = app.TableFittedParameters.Data(:,3);
s.fitted_parameters_upper_bound = app.TableFittedParameters.Data(:,4);
s.number_components = app.number_components;
s.select_a = app.TableParameters.Data.(5);
s.number_points = app.NumberofpointsEditField.Value;
s.point_space = app.PointSpaceDropDown.Value;
s.error_type = app.ErrortominimizeDropDown.Value;
s.input_path = app.InputDatasetPath.Value;
s.horizontal_axis = app.HorizontalaxisfieldDropDown.Value;
s.vertical_axis = app.VerticalaxisfieldDropDown.Value;
s.curve_type = app.CurveDropDown.Value;
s.description = app.DescriptionTextArea.Value;
s.data_set_path = app.OutputDatasetPath.Value;
s.experimental_anhysteretic_magnetization_file_name = app.EditFieldFileNameExperimentalMagnetizationData.Value;
s.magnetization_file_name = app.EditFieldFileNameModeledAnhystereticMagnetization.Value;
s.parameters_file_name = app.EditFieldFileNameParameters.Value;
s.magnetization_plots_file_name = app.EditFieldFileNamePlotMagnetization.Value;
s.suceptibility_plots_file_name = app.EditFieldFileNamePlotSusceptibility.Value;
s.magnetization_derivative_file_name = app.EditFieldFileNamePlotSemiLogMagDerivative.Value;
s.magnetization_residual_file_name = app.EditFieldFileNameResiduesMagnetization.Value;
s.susceptibility_residual_file_name = app.EditFieldFileNameResiduesSusceptibility.Value;
s.semi_log_derivative_file_name = app.EditFieldFileNameResiduesSemiLogMagDerivative.Value;
s.log_checkbox = app.logCheckBoxInputPlot.Value;
s.fitting_log_checkbox = app.logCheckBoxHdMdH.Value;
s.fitting_show_grid_checkbox = app.ShowgridCheckBoxHdMdH.Value;
s.fitting_plot_components_checkbox = app.PlotcomponentsCheckBoxHdMdH.Value;
s.model_magnetization_checkbox = app.CheckBoxOutputMagnetizationDataFittedAnhystereticMagnetization.Value;
s.model_magnetization_components_checkbox = app.OutputSeparateComponentsCheckBox.Value;
s.fitted_parameters_checkbox = app.ExportFittedparametersCheckBox.Value;
s.model_parameters_checkbox = app.ExportModelparametersCheckBox.Value;
s.other_quantities_checkbox = app.ExportOtherquantitiesCheckBox.Value;
s.errors_checkbox = app.ExportErrorsCheckBox.Value;
s.magnetization_plots_checkbox = app.CheckBoxExportPlotMagnetization.Value;
s.susceptibility_plots_checkbox = app.CheckBoxExportPlotSusceptibility.Value;
s.magnetization_derivatives_checkbox = app.CheckBoxExportPlotSemiLogMagDerivative.Value;
s.experimental_anhysteretic_magnetization_checkbox = app.CheckBoxExperimentalMagnetization.Value;
s.magnetization_residual_checkbox = app.CheckBoxExportResiduesMagnetization.Value;
s.susceptibility_residual_checkbox = app.CheckBoxExportResiduesSusceptibility.Value;
s.semi_log_derivative_residual_checkbox = app.CheckBoxExportResiduesSemiLogMagDerivative.Value;
data = jsonencode(s, PrettyPrint=true);
fprintf(file, "%s", data);
fclose(file);
app.write_message("Project saved at " + app.ProjectPath);
end
end
methods (Access = public)
function set_colors_and_plot(app, colors)
app.Colors = colors;
update_components(app)
calculate_parameters(app)
plot(app)
end
function a = calculate_and_plot(app)
path = app.InputDatasetPath.Value;
if isfile(path)
app.import_data(path);
update_components(app)
calculate_parameters(app)
app.plot_input();
a = 0;
else
app.write_message(path + " was not found, please browse the dataseth path again");
a = -1;
end
end
end
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
addpath(".\src");
import_src();
app.ProjectPath = "";
app.number_components = app.NumberofcomponentsSpinner.Value;
app.init_components();
app.TableFittedParameters.ColumnFormat = {[] 'short' 'short' 'short' 'logical'};
app.init_parameters_table(true);
for i=1:5
addStyle(app.TableParameters, uistyle('HorizontalAlignment','right'), "column", i)
end
app.init_quantities_table(true);
for i=1:5
addStyle(app.TableQuantities, uistyle('HorizontalAlignment','right'), "column", i)
end
update_components(app)
% Each element from the array represents RGB on scale 0-1
app.Colors = [ 0.58 0 0.70; 0.70 0 0; 0 0 0.70; 0 0.70 0; 1 0.50 0];
app.OutputDatasetPath.Value = strcat(pwd(), '\data');
msg = sprintf("[%s] %s", app.get_time_string(), "MagAnalyst 1.0.2-beta");
app.MessagesTextArea.Value(end) = cellstr(msg);
end
% Button pushed function: FitButton
function FitButtonPushed(app, event)
update_components(app)
fit_parameters(app)
calculate_parameters(app)
plot(app)
end
% Button pushed function: CalculatePlotButton
function CalculatePlotButtonPushed(app, event)
update_components(app)
calculate_parameters(app)
plot(app)
end
% Value changed function: logCheckBoxM
function logCheckBoxMValueChanged(app, event)
app.plot_M()
end
% Value changed function: logCheckBoxdMdH
function logCheckBoxdMdHValueChanged(app, event)
app.plot_dMdH()
end
% Value changed function: logCheckBoxHdMdH
function logCheckBoxHdMdHValueChanged(app, event)
app.plot_HdMdH()
end
% Value changed function: NumberofcomponentsSpinner
function NumberofcomponentsSpinnerValueChanged(app, event)
app.number_components = app.NumberofcomponentsSpinner.Value;
app.init_components();
end
% Button pushed function: InputBrowseButton
function InputBrowseButtonPushed(app, event)
[file,path] = uigetfile('*.csv','Select dataset file', '.\data');
if strcat(path, file) == ""
return
end
try
app.import_data(strcat(path, file));
app.InputDatasetPath.Value = strcat(path, file);
update_components(app)
calculate_parameters(app)
app.write_message("Imported " + file);
app.plot_input();
catch e
app.write_message("Import failed: " + e.message);
end
end
% Value changed function: InputDatasetPath
function InputDatasetPathValueChanged(app, event)
dataset_path = app.InputDatasetPath.Value;
[app.H, app.M] = Parser(dataset_path).get_data_csv;
update_components(app)
calculate_parameters(app)
end
% Value changed function: logCheckBoxInputPlot
function logCheckBoxInputPlotValueChanged(app, event)
if app.InputDatasetPath.Value == ""
return
end
app.plot_input()
end
% Button pushed function: ResidualplotButtonM
function ResidualplotButtonMPushed(app, event)
residue_calculator = MagnetizationResidueCalculator(app.data_curve, app.modeled_curve);
residue = residue_calculator.get_residue();
residue_plotter = ResiduePlotter(app.data_curve.H, app.data_curve.M, app.modeled_curve.H, app.modeled_curve.M, residue, app.logCheckBoxM.Value, "M [A/m]");
residue_plotter.plot()
end
% Button pushed function: ResidualplotButtondMdH
function ResidualplotButtondMdHPushed(app, event)
residue_calculator = SusceptibilityResidueCalculator(app.data_curve, app.modeled_curve);
residue = residue_calculator.get_residue();
residue_plotter = ResiduePlotter(app.data_curve.H, app.data_curve.dMdH, app.modeled_curve.H, app.modeled_curve.dMdH, residue, app.logCheckBoxdMdH.Value, "∂M/∂H");
residue_plotter.plot()
end
% Button pushed function: ResidualplotButtondHdMdH
function ResidualplotButtondHdMdHPushed(app, event)
residue_calculator = SemilogDerivativeResidueCalculator(app.data_curve, app.modeled_curve);
residue = residue_calculator.get_residue();
residue_plotter = ResiduePlotter(app.data_curve.H, app.data_curve.HdMdH, app.modeled_curve.H, app.modeled_curve.HdMdH, residue, app.logCheckBoxHdMdH.Value, "∂M/∂(logH) [A/m]");
residue_plotter.plot()
end
% Button pushed function: OutputBrowseButton
function OutputBrowseButtonPushed(app, event)
app.OutputDatasetPath.Value = uigetdir(app.OutputDatasetPath.Value,'Select output folder');
end
% Button pushed function: ExportdataButton
function ExportdataButtonPushed(app, event)
if (app.CheckBoxOutputMagnetizationDataFittedAnhystereticMagnetization.Value == 0 && app.CheckBoxExperimentalMagnetization.Value == 0)
app.write_message("No magnetization data was selected to be exported.");
return;
end
if (app.CheckBoxOutputMagnetizationDataFittedAnhystereticMagnetization.Value == 1)
if(app.OutputSeparateComponentsCheckBox.Value == 0)
t = table(transpose(app.modeled_curve.H), transpose(app.modeled_curve.M), transpose(app.modeled_curve.dMdH), transpose(app.modeled_curve.HdMdH));
t.Properties.VariableNames(:) = {'H [A/m]' 'M [A/m]' 'dM/dH' 'dM/dlogH [A/m]' };
elseif(app.OutputSeparateComponentsCheckBox.Value == 1)
t = table(transpose(app.modeled_curve.H), transpose(app.modeled_curve.M), array2table(transpose(app.modeled_curve.Mi)), transpose(app.modeled_curve.dMdH), array2table(transpose(app.modeled_curve.dMidH)), transpose(app.modeled_curve.HdMdH), array2table(transpose(app.modeled_curve.HdMidH)));
t = splitvars(t);
variable_names = cell(4 + app.number_components*3, 1);
variable_names(1) = {'H [A/m]'};
variable_names(2) = {'M [A/m]'};
variable_names(app.number_components + 3) = {'dM/dH'};
variable_names(2*app.number_components + 4) = {'dM/dlogH [A/m]'};
for i=1:app.number_components
variable_names(i + 2) = cellstr(strcat('M', string(i), ' [A/m]'));
variable_names(i + app.number_components + 3) = cellstr(strcat('dM', string(i), '/dH'));
variable_names(i + 2*app.number_components + 4) = cellstr(strcat('dM', string(i), '/dlogH [A/m]'));
end
t.Properties.VariableNames = variable_names;
end
file_name = strcat(app.EditFieldFileNameModeledAnhystereticMagnetization.Value, app.DropDownOutputModeledAnhystereticMagnetizationExtension.Value);
path = strcat(app.OutputDatasetPath.Value, '\', file_name);
writetable(t,path, 'Delimiter', ';');
app.write_message("Modeled data saved as " + file_name);
end
%Separate into two functions
if(app.CheckBoxExperimentalMagnetization.Value == 1)
t = table(transpose(app.data_curve.H), transpose(app.data_curve.M));
t.Properties.VariableNames(:) = {'H [A/m]' 'M [A/m]'};
file_name = strcat(app.EditFieldFileNameExperimentalMagnetizationData.Value, app.DropDownOutputExperimentalMagnetizationData.Value);
path = strcat(app.OutputDatasetPath.Value, '\', file_name);
writetable(t,path, 'Delimiter', ';');
app.write_message("Experimental data saved as " + file_name);
end
end
% Value changed function: PlotcomponentsCheckBoxM
function PlotcomponentsCheckBoxMValueChanged(app, event)
app.plot_M()
end
% Value changed function: PlotcomponentsCheckBoxdMdH
function PlotcomponentsCheckBoxdMdHValueChanged(app, event)
app.plot_dMdH()
end
% Value changed function: PlotcomponentsCheckBoxHdMdH
function PlotcomponentsCheckBoxHdMdHValueChanged(app, event)
app.plot_HdMdH()
end
% Value changed function: ShowgridCheckBoxM
function ShowgridCheckBoxMValueChanged(app, event)
grid(app.AxesM,"off");
if(app.ShowgridCheckBoxM.Value == 1)
grid(app.AxesM,"on");
end
end
% Value changed function: ShowgridCheckBoxdMdH
function ShowgridCheckBoxdMdHValueChanged(app, event)
grid(app.AxesdMdH,"off");
if(app.ShowgridCheckBoxdMdH.Value == 1)
grid(app.AxesdMdH,"on");
end
end
% Value changed function: ShowgridCheckBoxHdMdH
function ShowgridCheckBoxHdMdHValueChanged(app, event)
grid(app.AxesHdMdH,"off");
if(app.ShowgridCheckBoxHdMdH.Value == 1)
grid(app.AxesHdMdH,"on");
end
end
% Button pushed function: SetColorsButton
function SetColorsButtonPushed(app, event)
app.SetColorsButton.Enable = false;
app.ColorDialogApp = colorDialog(app, app.Colors, app.number_components);
end
% Close request function: MagAnalystUIFigure
function MagAnalystUIFigureCloseRequest(app, event)
delete(app.ColorDialogApp)
delete(app)
end
% Button pushed function: ExportParametersButton
function ExportParametersButtonPushed(app, event)
if(app.ExportFittedparametersCheckBox.Value == 0 && app.ExportModelparametersCheckBox.Value == 0 && app.ExportOtherquantitiesCheckBox.Value == 0 && app.ExportErrorsCheckBox.Value == 0)
app.write_message("No parameters were selected to be exported");
return;
end
file_name = strcat(app.EditFieldFileNameParameters.Value, app.DropDownOutputParametersExtension.Value);
path = strcat(app.OutputDatasetPath.Value, '\', file_name);
file = fopen(path,'w');
fprintf(file, "Parameters:" + newline);
if(app.ExportFittedparametersCheckBox.Value == 1)
fprintf(file, "Fitted Parameters:" + newline);
for i = 1:height(app.TableFittedParameters.Data)
name = string(app.TableFittedParameters.Data(i, 1));
name = subscript_to_number(app, name);
value = str2double(app.TableFittedParameters.Data(i, 2));
s = sprintf("%s: \t%f", name, value);
fprintf(file, s + newline);
end
fprintf(file, newline);
end
if(app.ExportModelparametersCheckBox.Value == 1)
fprintf(file, "Model-Retrieved Parameters:" + newline);
for i = 1:height(app.TableParameters.Data)
Ms_value = str2double(app.TableParameters.Data(i, 2).Ms_col);
alpha_value = str2double(app.TableParameters.Data(i, 3).alpha_col);
a_value = str2double(app.TableParameters.Data(i, 4).a_col);
s_component = sprintf("Component: %i", i);
s_Ms_value = sprintf(" Ms%i [A/m]: \t%0.4f", i, Ms_value);
s_alpha_value = sprintf(" α%i: \t%0.4e", i, alpha_value);
s_a_value = sprintf(" a%i [A/m]: \t%0.4f", i, a_value);
fprintf(file, s_component + newline + s_Ms_value + newline + s_alpha_value + newline + s_a_value + newline);
end
fprintf(file, newline);
end
if(app.ExportOtherquantitiesCheckBox.Value == 1)
fprintf(file, "Calculated Quantities:" + newline);
for i = 1:height(app.TableQuantities.Data)
alpha_Ms_value = str2double(app.TableQuantities.Data(i, 2).dimensionless_alphaMs_col);
density_product_value = str2double(app.TableQuantities.Data(i, 3).density_product_col);
Hk_value = str2double(app.TableQuantities.Data(i, 4).Hk_col);
magnetic_permeability_value = str2double(app.TableQuantities.Data(i, 5).initial_relative_magnetic_permeability_col);
s_component = sprintf("Component: %i", i);
s_alpha_Ms_value = sprintf(" α%i|Ms%i|/(3a%i): \t%0.4f", i, i, i, alpha_Ms_value);
s_density_product_value = sprintf(" N%ikBT [J/m^3]: \t%0.4f", i, density_product_value);
s_Hk = sprintf(" Hk%i [A/m]: \t%0.4f", i, Hk_value);
s_magnetic_permeability_value = sprintf(" μrin%i: \t%i", i, magnetic_permeability_value);
fprintf(file, s_component + newline + s_alpha_Ms_value + newline + s_density_product_value + newline + s_Hk + newline + s_magnetic_permeability_value + newline);
end
fprintf(file, newline);
end
if (app.ExportErrorsCheckBox.Value == 1)
diagonal_error = DiagonalErrorCalculator(app.data_curve, app.modeled_curve).get_error();
horizontal_error = HorizontalErrorCalculator(app.data_curve, app.modeled_curve).get_error();
vertical_error = VerticalErrorCalculator(app.data_curve, app.modeled_curve).get_error();
s_diagonal_error = sprintf(" Diagonal error: \t%10.4e", diagonal_error);
s_horizontal_error = sprintf("Horizontal error: \t%10.4e", horizontal_error);
s_vertical_error = sprintf(" Vertical error: \t%10.4e", vertical_error);
s = "Errors:" + newline + s_diagonal_error + newline + s_horizontal_error + newline + s_vertical_error + newline;
fprintf(file, s + newline);
end
fclose(file);
app.write_message("Parameter data saved as " + file_name);
end
% Button pushed function: ExportPlotsButton
function ExportPlotsButtonPushed(app, event)
if (app.CheckBoxExportPlotMagnetization.Value == 0 && app.CheckBoxExportPlotSusceptibility.Value == 0 && app.CheckBoxExportPlotSemiLogMagDerivative.Value == 0)
app.write_message("No plots were selected to be exported");
return;
end
app.write_message("Exporting plots");
if (app.CheckBoxExportPlotMagnetization.Value == 1)
file_name = strcat(app.EditFieldFileNamePlotMagnetization.Value, app.DropDownPlotMagnetizacionExtension.Value);
path = strcat(app.OutputDatasetPath.Value, '\', file_name);
exportgraphics(app.AxesM,path,'Resolution',400);
message = strcat("Magnetization plots exported as ",file_name);
app.write_message(message);
end
if (app.CheckBoxExportPlotSusceptibility.Value == 1)
file_name = strcat(app.EditFieldFileNamePlotSusceptibility.Value, app.DropDownPlotSusceptibilityExtension.Value);
path = strcat(app.OutputDatasetPath.Value, '\', file_name);
exportgraphics(app.AxesdMdH,path,'Resolution',400);
message = strcat("Susceptibility plots exported as ",file_name);
app.write_message(message);
end
if(app.CheckBoxExportPlotSemiLogMagDerivative.Value == 1)
file_name = strcat(app.EditFieldFileNamePlotSemiLogMagDerivative.Value, app.DropDownPlotSemiLogMagDerivativeExtension.Value);
path = strcat(app.OutputDatasetPath.Value, '\', file_name);
exportgraphics(app.AxesHdMdH,path,'Resolution',400);
message = strcat("Semi-Log Magnetization Derivative plots exported as ",file_name);
app.write_message(message);
end
end
% Menu selected function: SaveasMenu
function SaveasMenuSelected(app, event)
[file,path] = uiputfile('*.txt','Save project', '.\data\project.txt');
app.ProjectPath = strcat(path, file);
app.save();
end
% Menu selected function: OpenMenu
function OpenMenuSelected(app, event)
app.write_message("Opening new project");
pause(0.01);
[file,path] = uigetfile('*.txt','Select project', '.\data');
app.ProjectPath = strcat(path, file);
data = fileread(app.ProjectPath);
s = jsondecode(data);
app.number_components = s.number_components;
app.init_components();
app.init_parameters_table(true);
app.init_quantities_table(true);
app.NumberofcomponentsSpinner.Value = app.number_components;
app.TableFittedParameters.Data(:,2) = s.fitted_parameters_value;
app.TableFittedParameters.Data(:,3) = s.fitted_parameters_lower_bound;
app.TableFittedParameters.Data(:,4) = s.fitted_parameters_upper_bound;
app.TableParameters.Data.(5) = cellstr(s.select_a);
app.TableParameters.Data.(5) = categorical(app.TableParameters.Data.(5), {'high', 'low'}, 'Ordinal', true);
app.NumberofpointsEditField.Value = s.number_points;
app.PointSpaceDropDown.Value = s.point_space;
app.ErrortominimizeDropDown.Value = s.error_type;
app.InputDatasetPath.Value = s.input_path;
app.HorizontalaxisfieldDropDown.Value = s.horizontal_axis;
app.VerticalaxisfieldDropDown.Value = s.vertical_axis;
app.CurveDropDown.Value = s.curve_type;
app.DescriptionTextArea.Value = s.description;
app.OutputDatasetPath.Value = s.data_set_path;
app.EditFieldFileNameExperimentalMagnetizationData.Value = s.experimental_anhysteretic_magnetization_file_name;
app.EditFieldFileNameModeledAnhystereticMagnetization.Value = s.magnetization_file_name;
app.EditFieldFileNameParameters.Value = s.parameters_file_name;
app.EditFieldFileNamePlotMagnetization.Value = s.magnetization_plots_file_name;
app.EditFieldFileNamePlotSusceptibility.Value = s.suceptibility_plots_file_name;
app.EditFieldFileNamePlotSemiLogMagDerivative.Value = s.magnetization_derivative_file_name;
app.EditFieldFileNameResiduesMagnetization.Value = s.magnetization_residual_file_name;
app.EditFieldFileNameResiduesSusceptibility.Value = s.susceptibility_residual_file_name;
app.EditFieldFileNameResiduesSemiLogMagDerivative.Value = s.semi_log_derivative_file_name;
app.logCheckBoxInputPlot.Value = s.log_checkbox;
app.logCheckBoxHdMdH.Value = s.fitting_log_checkbox;
app.ShowgridCheckBoxHdMdH.Value = s.fitting_show_grid_checkbox;
app.PlotcomponentsCheckBoxHdMdH.Value = s.fitting_plot_components_checkbox;
app.CheckBoxOutputMagnetizationDataFittedAnhystereticMagnetization.Value = s.model_magnetization_checkbox;
app.OutputSeparateComponentsCheckBox.Value = s.model_magnetization_components_checkbox;
app.ExportFittedparametersCheckBox.Value = s.fitted_parameters_checkbox;
app.ExportModelparametersCheckBox.Value = s.model_parameters_checkbox;
app.ExportOtherquantitiesCheckBox.Value = s.other_quantities_checkbox;
app.ExportErrorsCheckBox.Value = s.errors_checkbox;
app.CheckBoxExportPlotMagnetization.Value = s.magnetization_plots_checkbox;
app.CheckBoxExportPlotSusceptibility.Value = s.susceptibility_plots_checkbox;
app.CheckBoxExportPlotSemiLogMagDerivative.Value = s.magnetization_derivatives_checkbox;
app.CheckBoxExperimentalMagnetization.Value = s.experimental_anhysteretic_magnetization_checkbox;
app.CheckBoxExportResiduesMagnetization.Value = s.magnetization_residual_checkbox;
app.CheckBoxExportResiduesSusceptibility.Value = s.susceptibility_residual_checkbox;
app.CheckBoxExportResiduesSemiLogMagDerivative.Value = s.semi_log_derivative_residual_checkbox;
if (app.calculate_and_plot() == -1)
return
end
app.CalculatePlotButtonPushed();
app.write_message(file + " was opened successfully");
end