Hi, I have a 4D data file from MATLAB, call it X, that I want to analyze in R. The first 3 dimensions are x y z coordinates and the forth is a value in time. If you took a sample vector in matlab it would look like vec1 = X(x1, y1, z1, :) vec2 = X( x2, y2, z2, :) this would give you all values (I have 300 of them) corresponding to this (x1,y1,z1) point of X. Now I read the MATLAB datafile 4D X into R and want to address vec1 and vec2 in R and work with the fourth column values only. I tried something like X[ x1, y1, z1, ] to pull out the 4th column values but R tells me that X has incorrect dimensions. I'd like to start with being able to find say correlation between vec1 and vec2 Any suggestions? [[alternative HTML version deleted]]
Hi Katia, On Wed, Jun 29, 2011 at 12:50 PM, Katia Smirnova <katiasmirn at gmail.com> wrote:> Hi, I have a 4D data file from MATLAB, call it X, ?that I want to analyze in > R. The first 3 dimensions are x y z coordinates and the forth is a value in > time. > > If you took a sample vector in matlab it would look like > > vec1 = X(x1, y1, z1, :) > vec2 = X( x2, y2, z2, :) > > this would give you all values (I have 300 of them) corresponding to this > (x1,y1,z1) point of X. > > Now I read the MATLAB datafile 4D X into R and want to address vec1 and vec2 > in R and work with the fourth column values only.How did you import the MATLAB file?> I tried something like X[ x1, y1, z1, ] to pull out the 4th column values > but R tells me that X has incorrect dimensions.We need a description of X. dim(X) and str(X) might be good starts. You don't really provide enough information to be able to answer. Sarah -- Sarah Goslee http://www.functionaldiversity.org
Hi Sarah, I use readMat function, from R.matlab function. str(X) tells that X : num [1:64, 1:64, 1:21, 1:300] as I said, the first 3 columns are x,y,z coordinates. And I need all values in the last column correcponding to a given (x,y,z) coordinate. if you list the values of X, then they are non zero, but for some reason R tells that dim(X): NULL -- View this message in context: http://r.789695.n4.nabble.com/4D-data-acsess-tp3633552p3634004.html Sent from the R help mailing list archive at Nabble.com.
On Jun 29, 2011, at 4:56 PM, katarv wrote:> Hi Sarah, > > I use readMat function, from R.matlab function. > > str(X) tells that > > X : num [1:64, 1:64, 1:21, 1:300] as I said, the first 3 columns > are x,y,z > coordinates. And I need all values in the last column correcponding > to a > given (x,y,z) coordinate.You should be able to access those values with: X[1,1,1, ] or equivalently: X[1,1,1,1:300]> > if you list the values of X,> then they are non zero, but for some reason R > tells that dim(X): NULLNow that seems a bit odd. What happens if you try: Y <- X dim(Y) <- c(64,64,21,300) Y[ 1, 1, 1, ]> > -- > View this message in context: http://r.789695.n4.nabble.com/4D-data-acsess-tp3633552p3634004.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.David Winsemius, MD West Hartford, CT