How to add multiple scales on second y axis?

조회 수: 14 (최근 30일)
Yasser Mal
Yasser Mal 2021년 11월 26일
댓글: Rudha Khudhair Mohammed 2023년 5월 12일
I want to combine 4 results with different scales and units. like the bottom picture, but with 2 left y and 2 right y axes. is there a way i can do this in matlab?

답변 (1개)

Yusuf Suer Erdem
Yusuf Suer Erdem 2021년 11월 26일
Hi Yasser, could you try these codes below? Good luck.
clc; clear; close all;
x1 = 0:0.1:40;
y1 = 4.*cos(x1)./(x1+2);
x2 = 1:0.2:20;
y2 = x2.^2./x2.^3;
t = tiledlayout(1,1);
ax1 = axes(t);
plot(ax1,x1,y1,'-r')
ax1.XColor = 'r';
ax1.YColor = 'r';
ax2 = axes(t);
plot(ax2,x2,y2,'-k')
ax2.XAxisLocation = 'top';
ax2.YAxisLocation = 'right';
ax2.Color = 'none';
ax1.Box = 'off';
ax2.Box = 'off';
  댓글 수: 8
Yasser Mal
Yasser Mal 2021년 11월 28일
I've been using this code and it's only capable of plotting two sets of data. thanks again
Rudha Khudhair Mohammed
Rudha Khudhair Mohammed 2023년 5월 12일
Not the right answer

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

카테고리

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

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by