Matlab和“评估UIcontrol回调时出错”

时间:2015-06-28 11:12:06

标签: matlab

我有一个matlab文件,我不能在这里发布(3000行),其中包含许多从GUI中使用的函数。

我正在使用包含3000行的matlab文件,这些行具有如此多的设计GUI功能

当我使用Function A时,该函数与使用其他几个函数相关,并使其成为循环,通过花费很长时间运行很多次function A (1600-2000)次迭代。

当我达到400-500时,Matlab给了我

error : "Error while evaluation UIcontrol callback"

我必须杀死现有进程,然后退出Matlab并从上一次迭代中再次运行,这会产生错误。所以我的问题不是基于函数调用,而是基于内存或可能是临时内存。

是否可以通过Matlab增加临时内存使用量?

我最多会增加首选项“Java热记忆”,但这种偏好不会改变我的问题。

有没有办法解决这个问题?

脚本的一部分:

function CalculateManyOffset % It's Function A on this topic

mainfig         = FigHandle;
parameters      = get(mainfig,'UserData');

dbstop if error

NumberofProfiles = str2double(get(parameters.NumberofProfilesBox,'string'));
step = str2double(get(parameters.DistBetweenProfilesBox,'string'));

Alphabet=('A':'Z').';
[I,J] = meshgrid(1:26,1:26);
namered = [Alphabet(I(:)), Alphabet(J(:))];
namered = strvcat(namered)';

nameblue = [Alphabet(I(:)), Alphabet(J(:))];
nameblue = strvcat(nameblue)';

apostrophe = '''';

SaveNameDisplacementFile = [get(parameters.SaveNamebox,'string'),'.txt'];

a=0;
icounter = 0;
StartBlue = str2double(get(parameters.bluelinebox,'String'));
EndBlue = StartBlue + NumberofProfiles;
StartRed = str2double(get(parameters.redlinebox,'String'));
EndRed = StartRed + NumberofProfiles-15;
for i = StartBlue:step:EndBlue;
    icounter = icounter +1;
    jcounter = 0;
for j=StartRed:step:EndRed;  
    jcounter = jcounter +1;
    opthorz = [];
    maxGOF = [];
    a=[a(1)+1 length(StartRed:step:EndRed)*length(StartBlue:step:EndBlue)]
    %
    if a(1) >= 0 && a(1) <= 20000
    BlueLineDist  = 1*i;
    parameters.bluelinedist = i;
    RedLineDist = 1*j;
    parameters.redlinedist = j;
    parameters.i = icounter;
    parameters.j = jcounter;
    set(mainfig,'UserData',parameters,'HandleVisibility','callback'); % To update variable parameters for the function which use them (downside : BlueLine, RedLine, GetBlueProfile, GetRedProfile, CalculateOffset)
    BlueLine;
    RedLine;
    GetBlueProfile;
    GetRedProfile;
    CalculateOffset;        
% Now, reload variable parameters with new value calculate on previous functions
    mainfig         = FigHandle;
    parameters      = get(mainfig,'UserData');
    opthorz = parameters.opthorz;
    name = [num2str(namered(:,jcounter)'),num2str(nameblue(:,icounter)'),apostrophe];
    namefid2 = [num2str(namered(:,jcounter)'),' - ',num2str(nameblue(:,icounter)'),apostrophe];
    Distance = [num2str(RedLineDist),' - ',num2str(BlueLineDist)];
    maxGOF = parameters.maxGOF;
            % Create file with all displacements
    if a(1) == 1;   
        fid2 = fopen(SaveNameDisplacementFile,'w');         
        fprintf(fid2,['Profile red - blue\t','Distance (m) between profile red - blue with fault\t','Optimal Displacement\t','Goodness of Fit\t','20%% from Goodness of Fit\t','Minimal Displacement\t','Maximal Displacement \n']);
        fprintf(fid2,[namefid2,'\t',Distance,'\t',num2str(opthorz),'\t',num2str(maxGOF),'\t',num2str(parameters.ErrorGOF),'\t',num2str(parameters.ErrorDisp(1,1)),'\t',num2str(parameters.ErrorDisp(1,2)),'\n']);
    elseif a(1) ~= b(end);
        fid2 = fopen(SaveNameDisplacementFile,'a');
        fprintf(fid2,[namefid2,'\t',Distance,'\t',num2str(opthorz),'\t',num2str(maxGOF),'\t',num2str(parameters.ErrorGOF),'\t',num2str(parameters.ErrorDisp(1,1)),'\t',num2str(parameters.ErrorDisp(1,2)),'\n']);
    else
        fid2 = fopen(SaveNameDisplacementFile,'a');
        fprintf(fid2,[namefid2,'\t',Distance,'\t',num2str(opthorz),'\t',num2str(maxGOF),'\t',num2str(parameters.ErrorGOF),'\t',num2str(parameters.ErrorDisp(1,1)),'\t',num2str(parameters.ErrorDisp(1,2))]);
        fclose(fid2);
    end       
end
end
end

0 个答案:

没有答案