【发布时间】:2012-05-17 11:15:56
【问题描述】:
我一直在尝试在 MATLAB 中编写一个简单的脚本来绘制图像,询问用户是否要将其打印到文件中,并且(如果是)执行此操作。但是,我在 print() 函数中遇到了一个奇怪的错误。这是我的代码:
plot(X, Y, 'red');
choice = input('Do you want to print to file this 2D image ? [y/n] ', 'y');
if(choice=='Y' || choice=='y')
{
print(hFig, '-dpng', strcat(filename, '.png'));
}
如果运行,它会在 if 语句内停止并出现错误:
==> 在 161 处打印错误 err.message='';
???期间未分配的输出参数“varargout”(可能还有其他参数) 调用“C:\Programmi\MATLAB\R2010a\toolbox\matlab\graphics\print.m>print”。
==> 柱状图在 30 打印时出错(hFig, '-dpng', strcat(filename, '.png'));
为什么会出现此错误,如何避免此错误?
【问题讨论】:
-
这可能不是它,但你在某个地方设置了
hFig,对吧? -
@mathematical.coffee 是的,之前