Basic ploting and labeling
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
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
0 个评论
更多回答(1 个)
Pinga
2014-6-24
2 个评论
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!