我还是不明白你的问题,但是当我运行你的榜样,我得到以下错误的第三次迭代:
图使用错误
单输入必须是现有的数字手柄或从1到2147483646
错误ezplot> determineAxes(线563)
图(图)标量
整数;
ezplot> ezplot1(line 449)中的错误
cax = determineAxes(fig);
错误ezplot(线145)
[马力,CAX] = ezplot1(CAX中,f {1},乏,标签,
ARGS {:});
sym/ezplot错误(第72行)
h = ezplot(fhandle(f),[y(1)y(2)],[y(3)y(4)]);
错误minimal_example(第7行)
ezplot(I * X + J * Y + 1,[0,10,0,10])
(你问的下一个时间,请包括这种信息)。
会发生什么事是,为的情况下 - 在你的代码i
或j
,但在你的问题a
或b
- 无论是x
或y
被0
乘以你现在提供太多的输入参数。其中之一被解释为一个数字句柄,因此评估不能继续(因为没有数字与0
的句柄 - 所有数字都有一个整数值作为句柄,因此错误)。
以下代码通过提供ezplot
的数字句柄来缓解这种情况。另外,我已经改变i
和j
到a
和b
对应的命名你的问题:现在
syms x y
% define a figure and return the handle, f1
f1=figure;
% after initializing the figure, set hold on
hold on
for a = -1:0.5:1
for b = -1:0.5:1
% pass the figure handle, f1, to ezplot:
ezplot(a*x+b*y+1, [0,10,0,10],f1)
pause
end
end
,你会得到你的情节都行。
编辑
在a=0
或情况b=0
你可能会得到意想不到的结果,因为它被传递给ezplot
前的公式计算。因此0*y
将导致它从评估中消失。您可以绕过此行为而不是使用0
,使用floating point relative accuracy eps
:
syms x y
% define a figure and return the handle, f1
f1=figure;
% after initializing the figure, set hold on
hold on
for a = -1:0.5:1
for b = -1:0.5:1
% pass the figure handle, f1, to ezplot:
% add eps to a and b so that the will be as close to zero
% as possible but not truly zero
ezplot((a+eps)*x+(b+eps)*y+1, [0,10,0,10],f1);
pause
end
end
发生了什么不好的事情?你的代码是什么?它出错了哪里? – sth
这不是什么代码。其声明;报表;报表; ezplot(f,[0,10])。例如,如果没有x(a)的系数,则ezplot将系数y(b)解释为a和开关轴。 ezplot也改变最小值最大值,我不能指定它们,因为只剩下1个变量。 – user2820173
即使您的评论,它不是很清楚,你的问题/错误是什么。你能否发布一个[最小工作示例](http://sscce.org/),它能够重现你的问题? (换句话说,我想复制/粘贴你的问题的代码到我的Matlab,运行它,看看你看到的错误)。 – Schorsch