Basic ploting and labeling
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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!
0 Kommentare
Akzeptierte Antwort
dpb
am 24 Jun. 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
0 Kommentare
Weitere Antworten (1)
Pinga
am 24 Jun. 2014
2 Kommentare
dpb
am 24 Jun. 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
Siehe auch
Kategorien
Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!