I'm trying to plot various shapes. Using fplot, the axis scales as intended, until it reaches x = 5, and completely stops scaling. I've used a fixed x and y scale and everything graphs correctly, but for some reason, the axis refuses to scale correctly in auto mode.
if true
% code
end
num = 15;
positive = true;
z = recaman(num)
for i = 1:(num - 1)
disp(num2str(i))
plot_semi(z(1, i), z(1, i + 1), positive, '-blue');
positive = ~positive;
end
hold off;
function out = recaman(n);
seq =[];
cur = 0;
for i = (1:n);
if (any(ismember(seq, (cur - i))) || ((cur - i) <= 0))
seq = horzcat(seq, cur);
cur = cur + i;
else
seq = horzcat(seq, cur);
cur = cur - i;
end
end
out = seq;
end
function plot_semi(n1,n2,pos, color);
syms f(x);
f(x) = sqrt(((n2 - n1)/2.0).^2 - (x - ((n2 - n1)/2.0) - n1).^2 );
if pos
fplot(f(x), color);
else
fplot(-f(x), color);
end
axis fill;
drawnow();
hold on;
end

3 件のコメント

KSSV
KSSV 2018 年 10 月 11 日
The default intervel of fplot is [-5 5]. If you want more..you need to specify the limits.
Raiyyan Siddiqui
Raiyyan Siddiqui 2018 年 10 月 11 日
Is there a way to increase the default, while still allowing the graph to scale if the function exceeds the limits?
KSSV
KSSV 2018 年 10 月 11 日
Read the documentation...it has an option of specifying the limits to extend the default.

サインインしてコメントする。

 採用された回答

madhan ravi
madhan ravi 2018 年 10 月 11 日
編集済み: madhan ravi 2018 年 10 月 11 日

0 投票

An example:
h=fplot(x,[-20000 20000]) % from -20000 to 20000 the default is from -5 to 5 to change it you have to specify the Lima as shown

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Programming についてさらに検索

製品

リリース

R2018a

質問済み:

2018 年 10 月 11 日

編集済み:

2018 年 10 月 11 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by