Thread Subject: Creating new variables...

Subject: Creating new variables...

From: Arvind

Date: 6 Oct, 2009 15:57:03

Message: 1 of 3

Hi guys,

   I have a 4D matrix with image information (rows/columns of image data, number of slices per stack of images, and number of timepoints- that is, number of stacks of images). I want to extract just the rows/columns/number of slices per stack into new variables so I am able to use the implay command (implay cannot read 4d matrices). However, every unique set of 4d data may contain different timepoints, so in some cases I may need to make 4 new variables to store the 3d matrix, or maybe 14.

I've tried something along the lines of:
                 movie_tp=sprintf('mov%d',t) <--where 't' is the timepoint counter in the outermost for loop
                 mov_tempstore(r,c,s)=x(r,c,s,t); <---just storing specific information to the particular timepoint
                 assignin('base',movie_tp,mov_tempstore) <---assigning the data to the new variable 'mov1'
                  mov1 <---When I try to access 'mov1,' I get an error saying such a variable doesn't exist.

I think some really easy solution is flying over my radar, but I'd appreciate any help with this!

Thanks,
Arvind

Subject: Creating new variables...

From: Steven Lord

Date: 6 Oct, 2009 17:05:43

Message: 2 of 3


"Arvind " <ab835@georgetown.edu> wrote in message
news:hafpcf$ls9$1@fred.mathworks.com...
> Hi guys,
>
> I have a 4D matrix with image information (rows/columns of image data,
> number of slices per stack of images, and number of timepoints- that is,
> number of stacks of images). I want to extract just the
> rows/columns/number of slices per stack into new variables so I am able to
> use the implay command (implay cannot read 4d matrices). However, every
> unique set of 4d data may contain different timepoints, so in some cases I
> may need to make 4 new variables to store the 3d matrix, or maybe 14.

M = rand(100, 100, 3, 10); % 100-by-100 image, 3 slices per stack, 10 time
points
for k = 1:10
    subplot(5, 2, k);
    imshow(M(:, :, :, k)) % Treat this as an RGB image, showing each time
step in its own subplot
end

Of course, with random data, that's not likely to be very interesting, but
it should be more interesting when you adapt it to your needs.

> I've tried something along the lines of:
> movie_tp=sprintf('mov%d',t) <--where 't' is the timepoint
> counter in the outermost for loop
> mov_tempstore(r,c,s)=x(r,c,s,t); <---just storing
> specific information to the particular timepoint
> assignin('base',movie_tp,mov_tempstore) <---assigning
> the data to the new variable 'mov1'


DO NOT DO THIS. See the newsgroup FAQ for an explanation why you shouldn't.

> mov1 <---When I try to access 'mov1,' I get an error
> saying such a variable doesn't exist.
>
> I think some really easy solution is flying over my radar, but I'd
> appreciate any help with this!

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Subject: Creating new variables...

From: Arvind

Date: 6 Oct, 2009 19:12:03

Message: 3 of 3

Unless I'm missing something, doesn't your code just output the images? I'd like to store each 3d set of data into a new variable, and have the program generate new 3D variables by the timepoint element in any given vector.

I'd appreciate your help!

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Contact us at files@mathworks.com