concatenation of multiple vector variables and display in a single matrix variable

Hello.. I am writing a matlab code for ecg signal processing. Here I get many intermediate results like R peak values, R peak locations, R-R distances, QRS width etc for each ecg in an ecg file. All these results are 1*x vectors. I want to combine all of them and display in a single matrix of say x*y at the end for easy analysis of all the results. ie, each row should represent different parameters like peaks, locetions, RR distance, QRS width, etc and each column should represent the sample number/time instances. Is it possible to achieve this? Can anybody tell me how can i do this? ( I hope my doubt is clear to you all.) Thank you.

 Accepted Answer

E.g.,
R_values = 1 x X vector of peak values
R_locations = 1 x X vector of peak locations
R_distances = 1 x X vector of distances
etc
R = [R_values; R_locations; R_distances; etc]'; % an X x Y matrix of results

7 Comments

I'm sorry to say this but it does not worked for me. Now I am getting R as matrix of 1*2X. Here is the piece of my code:
[pks,locs] = findpeaks(ecg_m,'MINPEAKDISTANCE',0.2*fs); pks1=pks; locs1=locs; R=[pks1,locs1];
% pks1 is 1*34 double, locs1 is 1*34 double. R is 1*68 double.
You used a comma instead of a semi-colon which I had specified above. Instead of doing this:
R=[pks1,locs1];
You should be doing this (note the semi-colon and the single-quote):
R=[pks1;locs1]';
Oh..It was completely my mistake. I apologize for that. I am happy to say that it worked. And that single quote is to transpose the matrix. Thank you very much.
Better habit to learn would be to transpose the matrix using the non-conjugate transpose:
R=[pks1;locs1].';
Can you please explain me the difference between R=[pks1;locs1]'; and R=[pks1;locs1].'; ?? Because when I tried both, I get the same effect.
The single quote ' is a complex conjugate transpose, while the period and single quote .' is a non-conjugate transpose. It is a good habit to use the non-conjugate transpose unless you specifically need a complex conjugate transpose for some linear algebra.
You can read more about the complex conjugate transpose here:

Sign in to comment.

More Answers (0)

Asked:

on 16 Sep 2015

Commented:

on 18 Sep 2015

Community Treasure Hunt

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

Start Hunting!