# Plotting 4 data sets on 2 y axis

3 visualizaciones (últimos 30 días)
Richard el 25 de Feb. de 2011
Respondida: Andreas el 18 de Mayo de 2020
I have searched matlab help, and various forums for an answer to this, so far without success, which is surprising, as it seems to be a relatively straight forward task.
I currently have 4 data sets that I have imported from a csv file, which are all charted against time (I have also created a time vector to plot against). The 4 data sets are EMG data, which shows muscle usage, as a voltage between 0 and 0.3, and then the angle of the ankle, knee, and relative angle between the two, all of which are in degrees.
What I'm wanting to do is put volts up the left axis, and degrees up the right (or visa-versa), then plot the 4 lines, preferably in different colours, and add a legend. So far all I have really come up with is plotyy, which seems to be happy plotting two of the data sets against each other on 2 axis, but not 4.
Any help would be very much appreciated!
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (2)

the cyclist el 25 de Feb. de 2011
I've never done this before, and I am definitely not sure this is the best way, but it is a way.
time = 1:10;
y1 = 1:10;
a1 = 2:11;
a2 = 3:12;
a3 = 4:13;
figure
hold on
[ax,h1,h2] = plotyy(time,y1,repmat(time,[3 1])',[a1;a2;a3]');
legend([h1;h2],{'volts','angle 1','angle 2','angle 3'})
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Andreas el 18 de Mayo de 2020
Answer maybe a bit outdated, but according to this
maybe use
yyaxis right
or
yyaxis left
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Line Plots en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by