Borrar filtros
Borrar filtros

Basic ploting and labeling

2 visualizaciones (últimos 30 días)
Pinga
Pinga el 24 de Jun. de 2014
Comentada: Pinga el 29 de Jun. de 2014
Hi everyone!
I'm completely new to Matlab and although I've managed to get used to this new software, I'm still struggling with some really basic, beginner problems. I've a 15000x4 cell with EMG-data I've gotten from measurements. With "plot(EMGData{1,1}(:,2))" I've managed to plot all the data from column 2. Where I get stuck: 1. I want to plot column 3 in the same plot. 2. At the moment, both axes are labeled by default with the number of the rows/colums. Instead of having 15000 in the x-axes, I rather want to x-axes to display column 1 (the same with the y-axes, which I'd like to display column 2 and 3).
I'm aware that these are some basic questions but all the tutorials are quite advanced, so I coulnd't manage to solve these problems by myself.
Thank you in advance for your help!

Respuesta aceptada

dpb
dpb el 24 de Jun. de 2014
The questions are answered in the "Getting Started" sections of the documentation on array and cell array addressing...need to just spend a little time working thru the examples from the beginning; indeed, the documentation for the various functions themselves do presume a basic understanding of Matlab syntax.
For your specific questions, it's a pretty straightforward extension of what you already have written--
1)
plot(EMGData{1,1}(:,2:3)) % plot the 2nd:(thru:)3rd columns vs position
2)
plot(EMGData{1,1}(:,1),EMGData{1,1}(:,2:3)) % plot against the x-axis value from column 1
Specifically
doc colon
explains use of ":" in subscripting expressions

Más respuestas (1)

Pinga
Pinga el 24 de Jun. de 2014
Thank you very much! That works pretty well now. There is one more question: The data are equally distributed in 26 cells (each cell contains 15000 rows. I know would like to get all the data from each row 2 and 3 in one plot for the first 5 measurements. I therefore tried to do a straightforward extension as written before:
  • plot(EMGData{1,1}{1,1}{:,1},EMGData{1,1}{:,1:5}(:,2:3))Than it returns "Bad cell reference operation."
  2 comentarios
dpb
dpb el 24 de Jun. de 2014
That's a little more of a challenge--Matlab doesn't implement the full complement of nested referencing one would like, unfortunately.
IIUC what the organization is and what you want it would be something like
X=Dat{1:5}(2:3,:);
which looks like it should be the first five cell arrays dereferenced to their values and then the 2nd:3rd rows, all columns. But, multi-level indexing only works for a single cell at a time.
Consequently, you have to write either a loop or use cellfun or explicitly concatenate to get the selected subsets...
In a case here where sizes are known, it's just as easy to use the looping solution...
X=zeros(5*2,length(rows)); % preallocate
for i=1:5
X(2*i-1:2*i,:)=Dat{i}(2:3,:);
end
Pinga
Pinga el 29 de Jun. de 2014
Thank you very much! Yes, that's exactly what I want Mathlab to do. I'll try the looping solution.

Iniciar sesión para comentar.

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by