Basic ploting and labeling

2 次查看(过去 30 天)
Pinga
Pinga 2014-6-24
评论: Pinga 2014-6-29
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!

采纳的回答

dpb
dpb 2014-6-24
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

更多回答(1 个)

Pinga
Pinga 2014-6-24
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 个评论
dpb
dpb 2014-6-24
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 2014-6-29
Thank you very much! Yes, that's exactly what I want Mathlab to do. I'll try the looping solution.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by