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 manipulation

Subject: matrix manipulation

From: kalyani sundaram

Date: 2 May, 2011 13:32:05

Message: 1 of 6

Dear all,
            I need to create a matrix of size 256x256 .I want to put it in a loop.First I need to call 8x8 matrix(1:8,1:8) and fill all with same value.Next I have to call another 8x8 matrix (1:8,9:16) and fill all with same value (value is different from the first one).Similarly I need to complete entire matrix of size 256x256.Can anyone help me with matlab code for the same or give me an idea how to proceed.
Thanks

Subject: matrix manipulation

From: Florin Neacsu

Date: 2 May, 2011 17:45:26

Message: 2 of 6

"kalyani sundaram" <kalyani@svce.ac.in> wrote in message <ipmbol$hg6$1@fred.mathworks.com>...
> Dear all,
> I need to create a matrix of size 256x256 .I want to put it in a loop.First I need to call 8x8 matrix(1:8,1:8) and fill all with same value.Next I have to call another 8x8 matrix (1:8,9:16) and fill all with same value (value is different from the first one).Similarly I need to complete entire matrix of size 256x256.Can anyone help me with matlab code for the same or give me an idea how to proceed.
> Thanks

Hi,

You could probably do it without a for loop, but here is a way with one

n=256;
A=zeros(n);
step=8;
k=0;
ll=n/step; %warning maybe?
values=1:(ll*ll); %input your values here

for ii=1:ll
    for jj=1:ll
      k=k+1;
      temp=values(k)*ones(step);
      A((ii-1)*step+1:ii*step,(jj-1)*step+1:jj*step)=temp;
    end
end

Regards,
Florin

Subject: matrix manipulation

From: Barry Williams

Date: 2 May, 2011 18:03:07

Message: 3 of 6

"kalyani sundaram" <kalyani@svce.ac.in> wrote in message <ipmbol$hg6$1@fred.mathworks.com>...
> Dear all,
> I need to create a matrix of size 256x256 .I want to put it in a loop.First I need to call 8x8 matrix(1:8,1:8) and fill all with same value.Next I have to call another 8x8 matrix (1:8,9:16) and fill all with same value (value is different from the first one).Similarly I need to complete entire matrix of size 256x256.Can anyone help me with matlab code for the same or give me an idea how to proceed.
> Thanks

It's not clear why you're doing this with a loop if the values are repeated:

x=5;
m=zeros(8,8);
m(:,:)=x;

 >>m

m =

     5 5 5 5 5 5 5 5
     5 5 5 5 5 5 5 5
     5 5 5 5 5 5 5 5
     5 5 5 5 5 5 5 5
     5 5 5 5 5 5 5 5
     5 5 5 5 5 5 5 5
     5 5 5 5 5 5 5 5
     5 5 5 5 5 5 5 5

Subject: matrix manipulation

From: kalyani sundaram

Date: 7 May, 2011 02:18:05

Message: 4 of 6

Dear Florin,
Thanks for your timely help.The code works well for my project.
I am doing block processing in my project.How to write code for block processing with overlapping blocks.since by using the command 'blockproc' we can do non-overlapping block processing.
Thanks

Subject: matrix manipulation

From: kalyani sundaram

Date: 7 May, 2011 02:20:20

Message: 5 of 6

Dear Barry,
      Thanks for your help.Could you please give me a code for dividing an image into blocks.(overlapping blocks).

Subject: matrix manipulation

From: Brendan Hannigan

Date: 7 May, 2011 17:18:04

Message: 6 of 6

"kalyani sundaram" <kalyani@svce.ac.in> wrote in message <iq2a94$hlr$1@newscl01ah.mathworks.com>...
> Dear Barry,
> Thanks for your help.Could you please give me a code for dividing an image into blocks.(overlapping blocks).

blockproc support overlapping blocks. go read the documentation.

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