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:
addition matrix

Subject: addition matrix

From: sonia

Date: 20 Aug, 2010 14:53:04

Message: 1 of 5

Hello,
Can you please helpe me to plot the matrix 'YY' when i=1 to 200,
Here below a few lines of my program
My problem is when i do ( imshow(YY) ), i have it when the variable 'i=200' but I want to have the sum of all matrix YY when i=1 to 200.

%%%%%%
delta=0.2;
for i=2:200
    for m=1:N
        for n=1:N
            f(1)=f0;
            f(i)=f(i-1)+delta;
            H(i-1)=f(i-1).*(D(i-1)./B(i-1));
            YY(m,n)=exp(1j*H(i-1).*(m.^2+n.^2));
         end
    end
end
imshow(YY)
%%%%%%

Subject: addition matrix

From: Matt J

Date: 20 Aug, 2010 15:03:07

Message: 2 of 5

"sonia " <sonia_elwardi@yahoo.fr> wrote in message <i4m4sg$f53$1@fred.mathworks.com>...
> Hello,
> Can you please helpe me to plot the matrix 'YY' when i=1 to 200,
> Here below a few lines of my program
> My problem is when i do ( imshow(YY) ), i have it when the variable 'i=200' but I want to have the sum of all matrix YY when i=1 to 200.
>
> %%%%%%
> delta=0.2;
> for i=2:200
> for m=1:N
> for n=1:N
> f(1)=f0;
> f(i)=f(i-1)+delta;
> H(i-1)=f(i-1).*(D(i-1)./B(i-1));
> YY(m,n)=exp(1j*H(i-1).*(m.^2+n.^2));
> end
> end
> end
> imshow(YY)
> %%%%%%


delta=0.2;
msq=(1:m).^2;
nsq=(1:n).^2;
MN=bsxfun(@plus,msq.',nsq);
         
f(1)=f0; YY=0;

for i=2:200

            f(i)=f(i-1)+delta;
            H(i-1)=f(i-1).*(D(i-1)./B(i-1));
            YY=YY+exp(1j*H(i-1).*MN);

end


imshow(YY)

Subject: addition matrix

From: Matt J

Date: 20 Aug, 2010 15:14:04

Message: 3 of 5

"Matt J " <mattjacREMOVE@THISieee.spam> wrote in message <i4m5fa$nm7$1@fred.mathworks.com>...


> msq=(1:m).^2;
> nsq=(1:n).^2;
> MN=bsxfun(@plus,msq.',nsq);
=============

whoops, make that

squares=(1:N).^2;
MN=bsxfun(@plus,squares.',squares);

Subject: addition matrix

From: Matt J

Date: 20 Aug, 2010 15:26:05

Message: 4 of 5

A little more code optimization...


delta=0.2;
f=(0:199)*delta+f0;
H(1:199)=f(1:199).*D(1:199)./B(1:199);
         
YY=0;
squares=(1:N).^2;
MN=bsxfun(@plus,squares.',squares);

for i=2:200
   YY=YY+exp(1j*H(i-1).*MN);
end

imshow(YY)

Subject: addition matrix

From: sonia

Date: 21 Aug, 2010 12:08:04

Message: 5 of 5

"Matt J " <mattjacREMOVE@THISieee.spam> wrote in message <i4m6qd$mlv$1@fred.mathworks.com>...
> A little more code optimization...
>
>
> delta=0.2;
> f=(0:199)*delta+f0;
> H(1:199)=f(1:199).*D(1:199)./B(1:199);
>
> YY=0;
> squares=(1:N).^2;
> MN=bsxfun(@plus,squares.',squares);
>
> for i=2:200
> YY=YY+exp(1j*H(i-1).*MN);
> end
>
> imshow(YY)

Thank you very much for your help,

I'm really appreciate your help, that 's exactly what i need

Regards
sonia

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