simple 2d x,y plot with another 2 x and y axis enabled

2 views (last 30 days)
I'd like to plot a simple 2d scatter that has all 4 axis enabled with preset scale factors.
e.g.
master x and y plot is a simple relationship of:
x1=0:1:50;
and then y1 is multiplied by a scale factor of, say, 10
y1=x1*10;
so I want to plot(x,y) BUT having another vertical (y2) and horizontal (x2) axis opposite to master x1 and y1 axis having their own scale factors, say, x2=x1^2 and y2=x1/1000 or whatever. Thank you.

Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 9 Mar 2013
Edited: Azzi Abdelmalek on 9 Mar 2013
Use plotyy
Example
x1=0:0.5:10;
y1=0.1*sin(0.1*x1);
x2=0:0.5:20;
y2=0.1*cos(0.1*x2);
[ax,h1,h2]=plotyy(x1,y1,x2,y2)
set(ax(2),'XaxisLocation','top','YaxisLocation','right')

Tags

Products

Community Treasure Hunt

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

Start Hunting!