필터 지우기
필터 지우기

Plot a figure with 2 x-axis and a single y-axis.

조회 수: 5 (최근 30일)
Sharath Yerneni
Sharath Yerneni 2020년 7월 14일
댓글: Sharath Yerneni 2020년 7월 15일
I am trying to plot a figure on matlab with 2 x-axis. The y-axis is y=x^2.
First x-axis is x and 2nd x-axis is 1/x as shown in figure.

답변 (1개)

Abhishek Gangwar
Abhishek Gangwar 2020년 7월 15일
clc;
clear;
close all;
x1 = 1:40;
y1 = x1.^2;
line(x1,y1,'Color','r')
ax1 = gca; % current axes
ax1.XColor = 'r';
ax1.YColor = 'r';
ax1_pos = ax1.Position; % position of first axes
ax2 = axes('Position',ax1_pos,...
'XAxisLocation','top',...
'YAxisLocation','right', ...
'Color','none');
x2 = 1./x1;
y2 = x2.^2;
line(x2,y2,'Parent',ax2,'Color','k');
  댓글 수: 1
Sharath Yerneni
Sharath Yerneni 2020년 7월 15일
Hi abhishek,
Thank your for your response. But that still doesn't answer my question. I just need 1 single plot with just 1 y-axis. Maybe my previous figure is unclear. Please look into the below figure. As far as I know, there is no possible way of doing this on matlab. I went through other questions but those couldn't answert this as well.

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

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by