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:
Shift matrix in y direction

Subject: Shift matrix in y direction

From: Aishwarya

Date: 20 Jul, 2010 22:48:04

Message: 1 of 3

Hello All,

I want to shift a (120,120) matrix spatially.I used the following program and got the final image shited along x, as in I am able to shift the data right and left.i am having trouble with shifting the data up and down.


clear all;
fid = fopen('Homo_noabs_S4D4.bin','r+');
A = fread(fid,'double');
a=reshape(A,120,120,120);
a=a(:,:,15);
figure,imagesc(a);
Y=a;
a=reshape(a,14400,1);
b=zeros(size(a));
for j=1:size(a(:))-3000
    b(j)=a(j+3000);
end
size(b);
b=reshape(b,120,120);
figure,imagesc(b);

Subject: Shift matrix in y direction

From: Walter Roberson

Date: 20 Jul, 2010 23:00:10

Message: 2 of 3

Aishwarya wrote:

> I want to shift a (120,120) matrix spatially.I used the following
> program and got the final image shited along x, as in I am able to shift
> the data right and left.i am having trouble with shifting the data up
> and down.
>
>
> clear all;
> fid = fopen('Homo_noabs_S4D4.bin','r+');
> A = fread(fid,'double');
> a=reshape(A,120,120,120);
> a=a(:,:,15);
> figure,imagesc(a);
> Y=a;
> a=reshape(a,14400,1);
> b=zeros(size(a));
> for j=1:size(a(:))-3000
> b(j)=a(j+3000);
> end
> size(b);
> b=reshape(b,120,120);
> figure,imagesc(b);

Have you considered using the optional arguments to imagesc() to specify the
positions of the corners of the images?

imagesc([1000 3000], [2000 4000], a)

would put the lower left corner at axes coordinates [1000, 2000] and would put
the upper right corner at axes coordinates [3000 4000]. (Not actually the
corners themselves, but for the precise details look at the documentation for
image() )

Subject: Shift matrix in y direction

From: Sean

Date: 21 Jul, 2010 13:59:06

Message: 3 of 3

"Aishwarya " <icemails@yahoo.co.in> wrote in message <i25934$7bs$1@fred.mathworks.com>...
> Hello All,
>
> I want to shift a (120,120) matrix spatially.I used the following program and got the final image shited along x, as in I am able to shift the data right and left.i am having trouble with shifting the data up and down.
>
>
> clear all;
> fid = fopen('Homo_noabs_S4D4.bin','r+');
> A = fread(fid,'double');
> a=reshape(A,120,120,120);
> a=a(:,:,15);
> figure,imagesc(a);
> Y=a;
> a=reshape(a,14400,1);
> b=zeros(size(a));
> for j=1:size(a(:))-3000
> b(j)=a(j+3000);
> end
> size(b);
> b=reshape(b,120,120);
> figure,imagesc(b);

If you have the image processing toolbox you could use my tool:
http://www.mathworks.com/matlabcentral/fileexchange/27251-imtranslate

Tags for this Thread

No tags are associated with 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