plotting logarithmic and linear scale

조회 수: 73 (최근 30일)
Brendan Clark
Brendan Clark 2021년 4월 11일
댓글: Brendan Clark 2021년 4월 11일
I'm working on an assignment that wants me to create a .m file that graphs both the linear and logarithmic scale.
The assignment is:
I have the script doing exactly what I need it to for the linear scale plot, however, I'm not sure how to also get matlab to transition it to log scale for the second set of plots. any help would be useful.
The code I have so far is:
t=linspace(0,20,1000);
speed=188.5*(1-exp(-0.4*t));
torque=10*exp(-0.4*t);
power=torque.*speed;
figure(1)
subplot(3,1,1)
plot(t,torque,'r-','LineWidth',2)
title('\bfPlot of Motor Output Torque\bf\it\tau\rm\bf_{IND},Speed\bf\it\omega_{m},and Power\bf\itP vs Time')
ylabel('\bf\itTorque, \tau\rm\bf_{IND}(N-m)')
grid on
subplot(3,1,2)
plot(t,speed,'r-','LineWidth',2)
ylabel('\bf\itSpeed, \omega_{m}\rm\bf(rad/s)')
grid on
subplot(3,1,3)
plot(t,power,'r-','LineWidth',2)
xlabel('\bfTime,t[s]')
ylabel('\bf\itPower, P\rm\bf(watts)')
grid on
the plots of the log scale should look like this:

채택된 답변

Andreas Apostolatos
Andreas Apostolatos 2021년 4월 11일
Hello,
You can use function 'semilogy' for your needs, please visit the following documentation page accordingly,
Simply replace command 'plot' with 'semilogy' and you should already obtain the desirable plots in logarithmic scale.
I hope this helps.
Kind Regards,
Andreas
  댓글 수: 1
Brendan Clark
Brendan Clark 2021년 4월 11일
Thank you! That was exactly what I was missing.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by