今天我在运行matlab程序的时候遇到了这个报错,现在解决了,给大家讲一讲怎么解决的。
首先这个问题在csdn上已经有些人讲过了,他们遇到的原因大多是自己本身就有同样名字的.m文件。
但是我这个就比较特别。大家可以先观察一下,如果你的报错尝试将 SCRIPT surf作为函数执行:后面的文件地址是在E:\MATLAB\R2018b\toolbox\matlab\graph3d这种类别的地方,那你就去按照这个路径去检查一下,你的surf文件是不是空的。
我这个软件本身就是在网上下的,可能有些漏洞,所以我下载以后我的surf.m文件压根就是空的,自然也就引用不了。如果是这个问题的话,大家复制一下surf.m的源代码放在那个空的文件里面就可以运行了。
我把源代码就放在下面了,有需要的朋友复制一下即可。
function h = surf(varargin)
%SURF 3-D colored surface.
% SURF(X,Y,Z,C) plots the colored parametric surface defined by
% four matrix arguments. The view point is specified by VIEW.
% The axis labels are determined by the range of X, Y and Z,
% or by the current setting of AXIS. The color scaling is determined
% by the range of C, or by the current setting of CAXIS. The scaled
% color values are used as indices into the current COLORMAP.
% The shading model is set by SHADING.
%
% S