Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
matrix reshaping problems

Subject: matrix reshaping problems

From: Pablo

Date: 17 Nov, 2010 03:36:04

Message: 1 of 1

I am trying to reshape a matrix where the first four vectors are dummy (nominal) variables:

[1 1 1 1 data1 data2 data3 ... data9 ]
[4 3 2 3 data26 ... ]
These first four nominal variables correspond to 4 Sites, 3 Treatments, 2 Sexes, and 3 Times. The matrix has dimensions of 1876 x 9 cells because the data distribution is not completely balanced. Because of this, a simple reshaping of the data matrix into a single vector is not possible.

For each set of site, treatment, sex, time group (between 15 and 30 rows of data) - there is a series of statistical calculations.

I created a series of loops to allow for these calculations, one set at a time using
for example:

for i=1:3 %identifying sites
idi=(data(:,1)==i); %identifies data for a particular site
site=data(idi,2:end); %reduces the data matrix to just those belonging to site=i.

.... And basically reducing the data matrix with a loop for each dummy variable until the matrix has the size of only an appropriate time (again, between 15 and 30 rows of code).
However, this seems too primitive and completely inelegant method. and mdscale function tends to choke due to the lack of balance at times.
Any help would be appreciated.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us