Semilogy not plotting onto log scale MATLAB R2017b
조회 수: 1 (최근 30일)
이전 댓글 표시
I'm supposed to submit a script to uni and one of the questions asked to plot Temperature against Time on a logarithmic scale but for some reason I can't get it to work.
% code
Time = [0;620;2266;3482];
Temperature = [62;56;40;32];
subplot(1,2,1)
plot(Time, Temperature,'-o');
subplot(1,2,2)
semilogy(Time, Temperature,'-o')
end
but the second subplot always appears with rectilinear scales.
However when I change the variables around so that it's
% code
Time = [0;620;2266;3482];
Temperature = [62;56;40;32];
subplot(1,2,1)
plot(Temperature, Time,'-o');
subplot(1,2,2)
semilogy(Temperature, Time,'-o')
end
It does show a log scale.
I know that the second one is not correct as according to the question it should roughly align with the function T(t) = b × (10)^mt where T=temperature and t=time.
댓글 수: 0
답변 (1개)
Star Strider
2018년 1월 7일
It is plotting correctly.
Try this, that includes a third subplot that does a linear plot of the log of ‘Temperature’:
figure(3)
Time = [0;620;2266;3482];
Temperature = [62;56;40;32];
subplot(1,3,1)
plot(Time, Temperature,'-o');
grid
subplot(1,3,2)
semilogy(Time, Temperature,'-o')
grid
subplot(1,3,3)
plot(Time, log10(Temperature),'-o')
yt = get(gca, 'YTick')
set(gca, 'YTick',yt, 'YTickLabel',10.^yt, 'YLim',log10([32 62]))
grid
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Two y-axis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!