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

查看:21
本文介绍了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.

Are 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天全站免登陆