필터 지우기
필터 지우기

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