私はまだあなたの質問を理解していませんが、あなたの例を実行すると、3回目の繰り返しで次のエラーが発生します:
Figure 使用エラー
単一入力は既存の Figure ハンドルまたは
1 ~ 2147483646 のスカラー整数で なければなりません
ezplot>determineAxes のエラー (563 行目)
figure(fig);
ezplot>ezplot1 のエラー (449 行目)
cax = determineAxes(fig);
ezplot のエラー (145 行目)
[hp, cax] = ezplot1(cax, f{1}, vars, labels,
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
乗算されている場合、入力引数が多すぎます。それらの 1 つが Figure ハンドルとして解釈されるため、評価を続行できません (ハンドルを持つ Figure がないため、すべての Figure はハンドルとして整数値を持つため、エラーが発生します)。
次のコードは、Figure ハンドルを に提供することで、これを軽減します。また、質問の命名法に対応するように とを変更しました。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
を使用する代わりに、浮動小数点の相対精度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