如何在显示非常大的数组时挂起MATLAB IDE? [英] How to interrupt MATLAB IDE when it hangs on displaying very large array?

查看:231
本文介绍了如何在显示非常大的数组时挂起MATLAB IDE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我正在使用MATLAB IDE并且碰巧在我的工作空间中有一些非常大的对象(例如500k +元素的数组)。现在,假设我愚蠢地偶然双击其中一个非常大的变量,这会触发对数组编辑器的加载。不幸的是,对于这么大的数组,MATLAB只是挂起。

Suppose I'm using the MATLAB IDE and happen to have some very large objects in my workspace (e.g. arrays of 500k+ elements). Now, suppose that I stupidly and accidentally double click on one of these very large variables, which triggers a load to the array editor. Unfortunately, with arrays this big, MATLAB just hangs.

我尝试过CTRL + C,CTRL + BREAK,CTRL + D,但似乎没有人能够中断IDE的行为。我知道我可以强制matlab退出,但是首先将所有这些变量读入工作区会花费很多时间,我可能在编辑器窗口中有未保存的更改等。

I've tried CTRL+C, CTRL+BREAK, CTRL+D, but none seem able to interrupt the behavior of the IDE. I know I can force matlab to quit, but reading all of those variables into the workspace in the first place takes a lot of time, and I may have unsaved changes in an editor window, etc.

推荐答案

我找到了一种方法,但它不是最好的,它需要更改路径并返回一次才能获得原始 openvar的句柄

I found a way, but it's not the best, it requires a change of path and back once to get a handle to the original openvar

function openvar(name,array)
    persistent org_openvar
    if isempty(org_openvar)
        curdir=pwd;
        cd(fullfile(matlabroot,'toolbox/matlab/codetools'));
        org_openvar = @openvar;
        cd(curdir);
    end

    if numel(array)>1e5
        if strcmp(questdlg(sprintf('Opening ''%s'' which has %d elements.\n\nAre you sure? This is gonna take a while!',name,numel(array)), ...
        'Variable editor','Yes','Cancel','Cancel') , 'Yes')
                org_openvar(name,array)
            end
    else
        org_openvar(name,array)
    end
end

获得该处理是最大的问题,称它没关系。如果内置 openvar ,您可以使用函数内置

getting that handle is the biggest problem, calling it is just fine. If openvar would be built in, you could use the function builtin:

builtin('openvar',name,array)

但不幸的是不是这样:(

str2func 结合完整路径也不起作用,至少我没有让它起作用。 ..

but this is unfortunately not the case :(
str2func in combination with the complete path also doesn't work, at least I don't get it to work...

这篇关于如何在显示非常大的数组时挂起MATLAB IDE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆