Create a diagram with 3 polynomials

I have defined 3 polynomials
P1 = [ 1 -2 -15]
P2 = [1 -7 12]
P3 = [1 1 -14 -24]
I want to generate a graph that will present the shape of all polynomials in range from -100 to 100 with specific description(the logarithmic axes)
How can I do it?

 採用された回答

Star Strider
Star Strider 2022 年 8 月 30 日

0 投票

I am not certain wht you want with ‘logarithmic axes’ so this creates both as logarithmic —
P1 = [ 1 -2 -15];
P2 = [1 -7 12];
P3 = [1 1 -14 -24];
x = linspace(-100, 100, 250);
V1 = polyval(P1,x);
V2 = polyval(P2,x);
V3 = polyval(P3,x);
figure
plot(x, [V1;V2;V3])
Ax = gca;
Ax.XScale = 'log'; % Logarithmic X-Axis
Ax.YScale = 'log'; % Logarithmic Y-Axis
grid
Warning: Negative data ignored
It may be best to only have the x-axis be logarithmic, and if so, consider using logspace instead of linspace.
.

4 件のコメント

Berkay
Berkay 2022 年 8 月 30 日
編集済み: Berkay 2022 年 8 月 30 日
If I change log as linear in here;
Ax.YScale = 'log';
Is Y-axis going to be linear and is X-axis still going to be log ?
Star Strider
Star Strider 2022 年 8 月 30 日
The axes scaling is set for each axis, so the axis settings are independent of each other.
The default axis scaling for all axes is 'linear' so if you want the y-scale to be linear, remove the line that sets it to 'log'. You can of course set it to 'linear' if you want to.
Berkay
Berkay 2022 年 8 月 30 日
thanks a lot man!!
Star Strider
Star Strider 2022 年 8 月 30 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeShifting and Sorting Matrices についてさらに検索

タグ

質問済み:

2022 年 8 月 30 日

コメント済み:

2022 年 8 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by