I made a logarithmic graph, and I want to add a continuous linear line that follows the equation y = x with x values from 1 to N.

1 回表示 (過去 30 日間)
Below is my code. My issue is that my continuous line is not showing on my graph. Since the log and linear plots are of diffrant magnitudes I used plotyy. so the left should be for log and the right for linear.
n = 100;
factorial = log10(cumprod(1:n));
semilogy(factorial);
title('Logarithmic Growth')
hold on
x = 1:n;
plotyy(n,factorial,n,x)
hold off

採用された回答

Voss
Voss 2023 年 2 月 8 日
Perhaps you mean:
plotyy(1:n,factorial,1:n,x)
  2 件のコメント
Joshua
Joshua 2023 年 2 月 8 日
Thank you I think that looks right!
Voss
Voss 2023 年 2 月 8 日
You're welcome!
The problem with
plotyy(n,factorial,n,x)
was that your x-coordinate is a scalar (n), so plotyy plots one line per y-coordinate (factorial or x), producing numerous lines, each with only one point, and you can't see a line that consists of only one point unless it has a data marker.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTwo y-axis についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by