필터 지우기
필터 지우기

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
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 CenterFile Exchange에서 Two y-axis에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by