Ezplot non-integer axis limits

6 ビュー (過去 30 日間)
Arun
Arun 2014 年 4 月 22 日
コメント済み: Arun 2014 年 4 月 22 日
Ezplot does not seem to let me use non integer axis limits.
I am trying to plot F which is a function of symbolic variable t ezplot(F,tmin:tmax) this seems to work only when tmin and tmax are integers so works for a range -1:1 but when I try -1:0.5 I get an error. Although -1:1 range shows values for 0.5.
Any ideas why this may be happening

採用された回答

Sean de Wolski
Sean de Wolski 2014 年 4 月 22 日
Here's what's happening. MATLAB is interpretting your expressions as necessary, when you say the limits are -1:0.5, it runs this:
-1:0.5
ans =
-1 0
And because the default stride is 1, it returns -1 and 0. These are then interpretted as your limits. I think you probably meant
ezplot(F,[-1 0.5]) or similar
Here's an example:
syms t
F = sin(t)*cos(t);
ezplot(F,2*[-pi pi])
  1 件のコメント
Arun
Arun 2014 年 4 月 22 日
Thanks a lot. It was silly of me the right syntax is of course what u said [xmin xmax] rather than [xmin:xmax]

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

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 4 月 22 日
Look at this example
f=@(x) x.^2
ezplot(f,[-1 1])
Have you an example which didn't work?

Community Treasure Hunt

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

Start Hunting!

Translated by