Slow array of structure updating in saving variables in app designer
I am working on developing an application in app designer for doing a bunch of fits and saving the results in an array of structures, where each structure has various types of fields about the fit results. When I save the file, I update the array with the fit_info structure each fit, and append to the array of structures for each save step. I eventually will be doing 89×13 fits. But, each cycle gets slower and slower, so it is impractically slow by about 30 fits. I looked into saving a separate variable for each fit, by dynamically naming the variables, i.e., fit_info_1_1, fit_info_1_2, etc., but I know this is bad programming practice. Does anyone have any suggestions?
function SaveFitButtonPushed(app, event)
data_source=string(app.TextArea.Value);
filename=strcat("fit_results_",data_source);
if isfile(filename)
matObj=matfile(filename,’Writable’,true);
matObj.fit_info_a(app.ColumnEditField.Value,app.CompoundEditField.Value)=app.fit_info_1;
else
fit_info_a(app.ColumnEditField.Value,app.CompoundEditField.Value)=app.fit_info_1;
save (filename,’fit_info_a’,’-v7.3′);
end
if ~isempty(app.fit_info_2.pm95)
data_source=string(app.TextArea.Value);
filename=strcat("fit_results_2_",data_source);
if isfile(filename)
matObj=matfile(filename,’Writable’,true);
matObj.fit_info_b(app.ColumnEditField.Value,app.CompoundEditField.Value)=app.fit_info_2;
else
fit_info_b(app.ColumnEditField.Value,app.CompoundEditField.Value)=app.fit_info_2;
save (filename,’fit_info_b’,’-v7.3′);
end
end
app.k_refS_1refS_2refTextArea.Value=”;
app.s_ETextArea.Value=”;
app.k_refS_1refS_2refTextArea_2.Value=”;
app.s_ETextArea_2.Value=”;
app.phi_refEditField.Value=30;
app.phi_refEditField_2.Value=30;
str='[]’;
app.OmitPointsEditField.Value=str;
app.OmitPointsEditField_2.Value=str;
endI am working on developing an application in app designer for doing a bunch of fits and saving the results in an array of structures, where each structure has various types of fields about the fit results. When I save the file, I update the array with the fit_info structure each fit, and append to the array of structures for each save step. I eventually will be doing 89×13 fits. But, each cycle gets slower and slower, so it is impractically slow by about 30 fits. I looked into saving a separate variable for each fit, by dynamically naming the variables, i.e., fit_info_1_1, fit_info_1_2, etc., but I know this is bad programming practice. Does anyone have any suggestions?
function SaveFitButtonPushed(app, event)
data_source=string(app.TextArea.Value);
filename=strcat("fit_results_",data_source);
if isfile(filename)
matObj=matfile(filename,’Writable’,true);
matObj.fit_info_a(app.ColumnEditField.Value,app.CompoundEditField.Value)=app.fit_info_1;
else
fit_info_a(app.ColumnEditField.Value,app.CompoundEditField.Value)=app.fit_info_1;
save (filename,’fit_info_a’,’-v7.3′);
end
if ~isempty(app.fit_info_2.pm95)
data_source=string(app.TextArea.Value);
filename=strcat("fit_results_2_",data_source);
if isfile(filename)
matObj=matfile(filename,’Writable’,true);
matObj.fit_info_b(app.ColumnEditField.Value,app.CompoundEditField.Value)=app.fit_info_2;
else
fit_info_b(app.ColumnEditField.Value,app.CompoundEditField.Value)=app.fit_info_2;
save (filename,’fit_info_b’,’-v7.3′);
end
end
app.k_refS_1refS_2refTextArea.Value=”;
app.s_ETextArea.Value=”;
app.k_refS_1refS_2refTextArea_2.Value=”;
app.s_ETextArea_2.Value=”;
app.phi_refEditField.Value=30;
app.phi_refEditField_2.Value=30;
str='[]’;
app.OmitPointsEditField.Value=str;
app.OmitPointsEditField_2.Value=str;
end I am working on developing an application in app designer for doing a bunch of fits and saving the results in an array of structures, where each structure has various types of fields about the fit results. When I save the file, I update the array with the fit_info structure each fit, and append to the array of structures for each save step. I eventually will be doing 89×13 fits. But, each cycle gets slower and slower, so it is impractically slow by about 30 fits. I looked into saving a separate variable for each fit, by dynamically naming the variables, i.e., fit_info_1_1, fit_info_1_2, etc., but I know this is bad programming practice. Does anyone have any suggestions?
function SaveFitButtonPushed(app, event)
data_source=string(app.TextArea.Value);
filename=strcat("fit_results_",data_source);
if isfile(filename)
matObj=matfile(filename,’Writable’,true);
matObj.fit_info_a(app.ColumnEditField.Value,app.CompoundEditField.Value)=app.fit_info_1;
else
fit_info_a(app.ColumnEditField.Value,app.CompoundEditField.Value)=app.fit_info_1;
save (filename,’fit_info_a’,’-v7.3′);
end
if ~isempty(app.fit_info_2.pm95)
data_source=string(app.TextArea.Value);
filename=strcat("fit_results_2_",data_source);
if isfile(filename)
matObj=matfile(filename,’Writable’,true);
matObj.fit_info_b(app.ColumnEditField.Value,app.CompoundEditField.Value)=app.fit_info_2;
else
fit_info_b(app.ColumnEditField.Value,app.CompoundEditField.Value)=app.fit_info_2;
save (filename,’fit_info_b’,’-v7.3′);
end
end
app.k_refS_1refS_2refTextArea.Value=”;
app.s_ETextArea.Value=”;
app.k_refS_1refS_2refTextArea_2.Value=”;
app.s_ETextArea_2.Value=”;
app.phi_refEditField.Value=30;
app.phi_refEditField_2.Value=30;
str='[]’;
app.OmitPointsEditField.Value=str;
app.OmitPointsEditField_2.Value=str;
end appdesigner, save, appending to file, array of structures MATLAB Answers — New Questions