1

I've a very large .mat file which contains a lot of data which I need to visualize. .mat file contains 5 row with each row containing 1x5 matrix - which contains the data. I need to concatenate specific rows together, then apply gmdistribution.fit to it. I'm not sure as to how exactly I access specific elements of the .mat file to concatenate them together.

Say I wish to concatenate first row - > 1st row with 2nd row - > 1st row. How would I go about doing this? I'm new to matlab and finding it difficult to grasp it.

Also, could you explain gmdistribution.fit, please? I read the documentation in their website, however, I still am not exactly sure about the parameters.

Thankyou for your help.

Shai
  • 111,146
  • 38
  • 238
  • 371
Mike Smith
  • 139
  • 2
  • 2
  • 12

1 Answers1

0

To access first row:

matrix(1);

To access second row:

matrix(2);

To vertically concatenate 1st and 2nd rows into a new matrix:

newMatrix = [matrix(1) ; matrix(2)];

And you can do this with any row in your matrix.

As for gmdistribution.fit, it is just trying to fit your matrix to a Gaussian distribution. Without a more specific question, all I can do is point you to the documentation, which holds and explains all the parameters.

panoptical
  • 782
  • 1
  • 8
  • 22
  • Thanks. I tried the following, which gave me an error. Could you tell me what I'm doing wrong? `filename = 'hello.mat'; A = load(filename); newMatrix = [A(1) ; A(2)];` – Mike Smith Feb 26 '13 at 02:22
  • `Error in ==> importdata at 5 newMatrix = [A(1) ; A(2)];` – Mike Smith Feb 26 '13 at 03:48
  • `gmdistribution.fit` does not fit a Gamma distribution. It fits a Gaussian mixture distribution. – Sam Roberts Feb 26 '13 at 11:33
  • Hello. I tried displaying the contents of the row, to see if it is accessing the data. `filename = 'hello.mat'; A = load(filename); B = A(1); disp(B);` I get the following result: hello: {5x1 cell}, which is the structure of the file. Might be my fault, I didn't explain the structure of the file well enough. It's a 5x1 (rowsxcolumn) matrix, with each row - when you double click it, contains 10 rows. Each of these rows - when you double click, contains very large amount of data. I'm not sure what this is called, as I have never come across something like this before. – Mike Smith Feb 26 '13 at 15:42
  • OK, my bad. They are cell arrays. Sorry, didn't realize data structure like that existed. – Mike Smith Feb 26 '13 at 21:07
  • Fixed the distribution name. – panoptical Feb 27 '13 at 14:28