How can I plot loglog(x,y) with an xlim and ylim?

I am trying to graph using loglog(x,y), however I am running into problems with a Negative data ignored message. Here is some of my code:
xlim([1,1000000])
ylim([0.000000000001,0.00001]);
a= [2300*10^(-9), 223.0*10^(-9), 5.30*10^(-12), 20.0*10^(-12), 2.19*10^(-12)];
b=[8.7, 135, 3289, 51290,10219];
y= a(1).*exp(-x./b(1));
loglog(x,y,'b');
Thanks!

 採用された回答

Mischa Kim
Mischa Kim 2014 年 3 月 6 日
編集済み: Mischa Kim 2014 年 3 月 6 日

1 投票

Christopher, move the xlim and ylim commands after the loglog command. Make sure that x > 0.

3 件のコメント

Christopher
Christopher 2014 年 3 月 6 日
編集済み: Christopher 2014 年 3 月 6 日
Mischa, I did what you said and moved it after the loglog command, and it worked! No more error, however, it won't graph the entire curve.. it stops abruptly at x=10^1. Thanks!
Mischa Kim
Mischa Kim 2014 年 3 月 6 日
編集済み: Mischa Kim 2014 年 3 月 6 日
How is x defined in your code? Note that with the xlim and ylim commands you define the axis limits. You need an additional command to define x values, e.g., using logspace
x = logspace(0,3,100); % define x: 100 data points btw. 10^0 and 10^3
a = [2300*10^(-9), 223.0*10^(-9), 5.30*10^(-12), 20.0*10^(-12), 2.19*10^(-12)];
b = [8.7, 135, 3289, 51290,10219];
y = a(1).*exp(-x./b(1));
loglog(x,y,'b');
xlim([1,1e6])
ylim([1e-12,1e-5]);
Christopher
Christopher 2014 年 3 月 6 日
Great! It worked, I forgot to define x!! Thanks again!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLog Plots についてさらに検索

質問済み:

2014 年 3 月 6 日

編集済み:

2014 年 3 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by