在-nodesktop模式下,Matlab fileread命令有什么限制? [英] What are the limitations of the Matlab fileread command in -nodesktop mode?

查看:942
本文介绍了在-nodesktop模式下,Matlab fileread命令有什么限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设一个7718个字符的文本文件(例如,从这里
$ b 当我使用<$ c $启动matlab时,命令 fileread('myfile.txt') c> matlab -nodesktop 但在桌面模式下工作。



有没有人知道为什么?



如果文本文件中的字符数减少到1981它在 -nodesktop 模式下工作。



注意:我不知道停止工作的字符的确切数量。


$ b $最后,我在Windows7上使用了Matlab 7.8.0(R2009a)。

解决方案

我无法重现奇怪的行为(Matlab 2010b& 2012b,都在Linux上)。

您至少可以尝试通过限制问题来调试这种类型的行为。 fileread例程会对文件名(ischar,isempty)进行一些检查,然后打开文件(fopen),读取文件(fread)并关闭文件(fclose) - 相当简单的基本功能。作为参考,在MATLAB桌面的命令行中键入编辑文件读取,并尝试逐步运行例行程序。

如果fread导致整个事件崩溃,并且绑定到此版本的Matlab,请尝试执行修复。 fread接受比fileread(文件ID和精度char)中使用的更多的参数:FREAD(FID,SIZE,PRECISION,SKIP,MACHINEFORMAT)。指定更多的参数可能有帮助(疯狂的猜测,但值得一试)。

Assuming a text file with 7718 characters (e.g. the contents cut and pasted from here)

The command fileread('myfile.txt') fails when I launch matlab with matlab -nodesktop but works in desktop mode.

Does anyone have any idea why?

If the number of characters in the text file is reduced to 1981 it works in -nodesktop mode.

Note:I do not know the exact number of characters at which it stops working.

Finally, I am using Matlab 7.8.0 (R2009a) on Windows7.

解决方案

I can't reproduce this odd behaviour (Matlab 2010b & 2012b, both on Linux).

You could at least try to "debug" this type of behaviour by restricting the problem. The "fileread" routine does some checks on the file name (ischar, isempty), then opens the file (fopen), reads it (fread) and closes it (fclose) - rather simple basic stuff. For reference, type "edit fileread" into the command line of the matlab desktop and try running down the routine step by step.

If "fread" causes the whole thing to crash and if you're bound to this version of Matlab, try implementing a "fix". "fread" accepts a few more parameters than what is used in "fileread" (the file ID and the precision "char" only): FREAD(FID,SIZE,PRECISION,SKIP,MACHINEFORMAT). Specifying more parameters may help (wild guess but worth a try).

这篇关于在-nodesktop模式下,Matlab fileread命令有什么限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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