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:
How to generate a full space array basing on the first quadrant's

Subject: How to generate a full space array basing on the first quadrant's

From: i2000s

Date: 4 Jan, 2011 17:47:10

Message: 1 of 6

Hi there,

I am trying to generate a 8n*4 array basing on a n*4 array. The n*4
array is a data base describe a physical parameter E(x, y, z) in a
quadrant, with every row in the format (x, ,y, z, E), and (x, y, z) is
the coordinate of the parameter. Along with the coordinate changing,
this array gives n rows to describe the E parameter in n places in the
first quadrant of space. And the 8n*4 array is just the mirror array
in full space with a symmetric or anti-symmetric value E to the first
quadrant. For example, if in x-axis the E is symmetric, so when x'<0,
E(x')=E(x) with x=-x'>0, when x'=x=0, E(x')=E(x); if in x-axis E is
anti symmetric, E(x')=-E(x) and E(0)=0. I can generate the E(x) in one
dimension, while this problem is not so easy, because we have three
coordinate indexes to label the E in full space. And my final goal is
get the full space parameter value array only basing on the first
quadrant value array.

Any help?

My code doesn't work ...
Thanks.

Best wishes,
Q

Subject: How to generate a full space array basing on the first quadrant's

From: Sean de

Date: 4 Jan, 2011 17:56:04

Message: 2 of 6

i2000s <e2000s@gmail.com> wrote in message <d3226a15-d1c6-4a0c-a6b1-997be6fda682@i18g2000yqn.googlegroups.com>...
> Hi there,
>
> I am trying to generate a 8n*4 array basing on a n*4 array. The n*4
> array is a data base describe a physical parameter E(x, y, z) in a
> quadrant, with every row in the format (x, ,y, z, E), and (x, y, z) is
> the coordinate of the parameter. Along with the coordinate changing,
> this array gives n rows to describe the E parameter in n places in the
> first quadrant of space. And the 8n*4 array is just the mirror array
> in full space with a symmetric or anti-symmetric value E to the first
> quadrant. For example, if in x-axis the E is symmetric, so when x'<0,
> E(x')=E(x) with x=-x'>0, when x'=x=0, E(x')=E(x); if in x-axis E is
> anti symmetric, E(x')=-E(x) and E(0)=0. I can generate the E(x) in one
> dimension, while this problem is not so easy, because we have three
> coordinate indexes to label the E in full space. And my final goal is
> get the full space parameter value array only basing on the first
> quadrant value array.
>
> Any help?
>
> My code doesn't work ...
> Thanks.
>
> Best wishes,
> Q

Show us the code you've tried!

And more importantly, show us a (small) example of input/rules/output; perhaps n=3?

Subject: How to generate a full space array basing on the first quadrant's

From: i2000s

Date: 4 Jan, 2011 19:45:38

Message: 3 of 6

On Jan 4, 12:56 pm, "Sean de "
<sean.dewol...@nospamplease.umit.maine.edu> wrote:
> i2000s <e20...@gmail.com> wrote in message <d3226a15-d1c6-4a0c-a6b1-997be6fda...@i18g2000yqn.googlegroups.com>...
> > Hi there,
>
> > I am trying to generate a 8n*4 array basing on a n*4 array. The n*4
> > array is a data base describe a physical parameter E(x, y, z) in a
> > quadrant, with every row in the format (x, ,y, z, E), and (x, y, z) is
> > the coordinate of the parameter. Along with the coordinate changing,
> > this array gives n rows to describe the E parameter in n places in the
> > first quadrant of space. And the 8n*4 array is just the mirror array
> > in full space with a symmetric or anti-symmetric value E to the first
> > quadrant.  For example, if in x-axis the E is symmetric, so when x'<0,
> > E(x')=E(x) with x=-x'>0, when x'=x=0, E(x')=E(x); if in x-axis E is
> > anti symmetric, E(x')=-E(x) and E(0)=0. I can generate the E(x) in one
> > dimension, while this problem is not so easy, because we have three
> > coordinate indexes to label the E in full space. And my final goal is
> > get the full space parameter value array only basing on the first
> > quadrant value array.
>
> > Any help?
>
> > My code doesn't work ...
> > Thanks.
>
> > Best wishes,
> > Q
>
> Show us the code you've tried!
>
> And more importantly, show us a (small) example of input/rules/output; perhaps n=3?
If I have to post my code, then I have to:
Correct the size of the reference array is wrong. In the array it
stores data in the form of A=(x, y, z, E) with xn*ym*zp space points,
where xn is the index number of x (definitely include 0) and so on,
and E has three components, so it has a size (xn, ym, zp, 3). And
another problem is I don't know whether the original array is in the
first quadrant: x,y,z are all set to symmetric/anti-symmetric, then A
is in the first quadrant; only two of x,y,z are set to symmetric/anti-
symmetric, then A is within two quadrant; if only one of x,y,z is set
to symmetric then A is within 4 quadrant; if none coordinate is
symmetric/anti-symmetric then A is in full space (do not need to
unwrap).

My code gives:

----------------------
Unwrap2FullSpace.m
----------------------
% input A and the symmetric index sym
n=100;m=101;p=102;
A=rand(n,m,p,1); %random mode data
Ex0=A; % for Ex component of E.
Ey0=A+1;
Ez0=A+2;
sym=[1,0,-1]; %symmetric setting for the data;1 means symmetric
setting,
                  % 0 no symmetric setting, -1 anti-symmetric setting
in corresponding entry
a=abs(sym); %parameter to judge whether it uses symmetric
setting
ft=sum(a); % unwrapped times
sizemode=[n m p];

% flipping the data
E=zeros(size(Ex0,1)*(1+a(1)),size(Ex0,2)*(1+a(2)),size(Ex0,3)*(1+a(3)),
3); % only consider Ex
label={'x','y','z'};
E(1:sizemode(1),1:sizemode(2),1:sizemode(3),1)=Ex0;
E(1:sizemode(1),1:sizemode(2),1:sizemode(3),2)=Ey0;
E(1:sizemode(1),1:sizemode(2),1:sizemode(3),3)=Ez0;

% only works for 3-D matrices without singlon
for ii=1:3
    if a(ii)==1
        E1=zeros(sizemode);
        E1(:,:,:)=squeeze(E(:,:,:,1)); %size mismatch
        E1=shiftdim(E1,ii);
        E1(1:sizemode(ii),:,:)=E1(sizemode(ii):-1:1,:,:);
        E1=shiftdim(E1,-ii);
        E1=flipdim(E1,ii);
        E(:,:,:,1)=squeeze(E(:,:,:,1))+sym(ii)*E1;

        E2=zeros(sizemode);
        E2(:,:,:)=squeeze(E(:,:,:,2));
        E2=shiftdim(E2,ii);
        E2(1:sizemode(ii),:,:)=E2(sizemode(ii):-1:1,:,:);
        E2=shiftdim(E2,-ii);
        E2=flipdim(E2,ii);
        E(:,:,:,2)=squeeze(E(:,:,:,2))+sym(ii)*E2;

        E3=zeros(sizemode);
        E3(:,:,:)=squeeze(E(:,:,:,3));
        E3=shiftdim(E3,ii);
        E3(1:sizemode(ii),:,:)=E3(sizemode(ii):-1:1,:,:);
        E3=shiftdim(E3,-ii);
        E3=flipdim(E3,ii);
        E(:,:,:,3)=squeeze(E(:,:,:,3))+sym(ii)*E3;


    end % flipping the data
end % counting dimenssion

% check the spatial symmetry for the unwrpped data
figure;
imagesc(squeeze(E(:,50,:,1)));
figure;
imagesc(squeeze(E(:,:,50,1)));
figure;
imagesc(squeeze(E(50,:,:,1)));
____________________________________

Problems:
1. dimension dismatch;
2. cannot exclude the duplicated data for x,y,z=0.
...

Thanks.

Subject: How to generate a full space array basing on the first quadrant's

From: i2000s

Date: 5 Jan, 2011 03:47:52

Message: 4 of 6

On Jan 4, 2:45 pm, i2000s <e20...@gmail.com> wrote:
> On Jan 4, 12:56 pm, "Sean de "
>
> <sean.dewol...@nospamplease.umit.maine.edu> wrote:
> > i2000s <e20...@gmail.com> wrote in message <d3226a15-d1c6-4a0c-a6b1-997be6fda...@i18g2000yqn.googlegroups.com>...
> > > Hi there,
>
> > > I am trying to generate a 8n*4 array basing on a n*4 array. The n*4
> > > array is a data base describe a physical parameter E(x, y, z) in a
> > > quadrant, with every row in the format (x, ,y, z, E), and (x, y, z) is
> > > the coordinate of the parameter. Along with the coordinate changing,
> > > this array gives n rows to describe the E parameter in n places in the
> > > first quadrant of space. And the 8n*4 array is just the mirror array
> > > in full space with a symmetric or anti-symmetric value E to the first
> > > quadrant.  For example, if in x-axis the E is symmetric, so when x'<0,
> > > E(x')=E(x) with x=-x'>0, when x'=x=0, E(x')=E(x); if in x-axis E is
> > > anti symmetric, E(x')=-E(x) and E(0)=0. I can generate the E(x) in one
> > > dimension, while this problem is not so easy, because we have three
> > > coordinate indexes to label the E in full space. And my final goal is
> > > get the full space parameter value array only basing on the first
> > > quadrant value array.
>
> > > Any help?
>
> > > My code doesn't work ...
> > > Thanks.
>
> > > Best wishes,
> > > Q
>
> > Show us the code you've tried!
>
> > And more importantly, show us a (small) example of input/rules/output; perhaps n=3?
>
> If I have to post my code, then I have to:
> Correct the size of the reference array is wrong. In the array it
> stores data in the form of A=(x, y, z, E) with xn*ym*zp space points,
> where xn is the index number of x (definitely include 0) and so on,
> and E has three components, so it has a size  (xn, ym, zp, 3). And
> another problem is I don't know whether the original array is in the
> first quadrant: x,y,z are all set to symmetric/anti-symmetric, then A
> is in the first quadrant; only two of x,y,z are set to symmetric/anti-
> symmetric, then A is within two quadrant; if only one of x,y,z is set
> to symmetric then A is within 4 quadrant; if none coordinate is
> symmetric/anti-symmetric then A is in full space (do not need to
> unwrap).
>
> My code gives:
>
> ----------------------
> Unwrap2FullSpace.m
> ----------------------
> % input A and the symmetric index sym
> n=100;m=101;p=102;
> A=rand(n,m,p,1);      %random mode data
> Ex0=A;                    % for Ex component of E.
> Ey0=A+1;
> Ez0=A+2;
> sym=[1,0,-1];      %symmetric setting for the data;1 means symmetric
> setting,
>                   % 0 no symmetric setting, -1 anti-symmetric setting
> in corresponding entry
> a=abs(sym);       %parameter to judge whether it uses symmetric
> setting
> ft=sum(a);        % unwrapped times
> sizemode=[n m p];
>
> % flipping the data
> E=zeros(size(Ex0,1)*(1+a(1)),size(Ex0,2)*(1+a(2)),size(Ex0,3)*(1+a(3)),
> 3); % only consider Ex
> label={'x','y','z'};
> E(1:sizemode(1),1:sizemode(2),1:sizemode(3),1)=Ex0;
> E(1:sizemode(1),1:sizemode(2),1:sizemode(3),2)=Ey0;
> E(1:sizemode(1),1:sizemode(2),1:sizemode(3),3)=Ez0;
>
> % only works for 3-D matrices without singlon
> for ii=1:3
>     if a(ii)==1
>         E1=zeros(sizemode);
>         E1(:,:,:)=squeeze(E(:,:,:,1)); %size mismatch
>         E1=shiftdim(E1,ii);
>         E1(1:sizemode(ii),:,:)=E1(sizemode(ii):-1:1,:,:);
>         E1=shiftdim(E1,-ii);
>         E1=flipdim(E1,ii);
>         E(:,:,:,1)=squeeze(E(:,:,:,1))+sym(ii)*E1;
>
>         E2=zeros(sizemode);
>         E2(:,:,:)=squeeze(E(:,:,:,2));
>         E2=shiftdim(E2,ii);
>         E2(1:sizemode(ii),:,:)=E2(sizemode(ii):-1:1,:,:);
>         E2=shiftdim(E2,-ii);
>         E2=flipdim(E2,ii);
>         E(:,:,:,2)=squeeze(E(:,:,:,2))+sym(ii)*E2;
>
>         E3=zeros(sizemode);
>         E3(:,:,:)=squeeze(E(:,:,:,3));
>         E3=shiftdim(E3,ii);
>         E3(1:sizemode(ii),:,:)=E3(sizemode(ii):-1:1,:,:);
>         E3=shiftdim(E3,-ii);
>         E3=flipdim(E3,ii);
>         E(:,:,:,3)=squeeze(E(:,:,:,3))+sym(ii)*E3;
>
>     end % flipping the data
> end     % counting dimenssion
>
> % check the spatial symmetry for the unwrpped data
> figure;
> imagesc(squeeze(E(:,50,:,1)));
> figure;
> imagesc(squeeze(E(:,:,50,1)));
> figure;
> imagesc(squeeze(E(50,:,:,1)));
> ____________________________________
>
> Problems:
> 1. dimension dismatch;
> 2. cannot exclude the duplicated data for x,y,z=0.
> ...
>
> Thanks.

I would like to give an example on 2D space's case:
If at the first quadrant, we have
A=[ 1 2 3;
    4 5 6;
    7 8 9]
with x-symmetry and y-anti-symmetry in full 2D space, then I expect to
get
E=[ 3 2 1 2 3;
    6 5 4 5 6;
    9 8 7 8 9;
   -9 -8 -7 -8 -9;
   -6 -5 -4 -5 -6;
   -3 -2 -1 -2 -3].
If it is in 3D space, then in z-axis, I also need to consider
expanding the size, if possible.

This problem just ask for an unfolding on 3D space but I have to judge
which dimension is set to be symmetric or anti-symmetric.

Have I make it clear?

Best wishes,
Q

Subject: How to generate a full space array basing on the first quadrant's

From: i2000s

Date: 5 Jan, 2011 03:50:33

Message: 5 of 6

On Jan 4, 10:47 pm, i2000s <e20...@gmail.com> wrote:
> On Jan 4, 2:45 pm, i2000s <e20...@gmail.com> wrote:
>
>
>
> > On Jan 4, 12:56 pm, "Sean de "
>
> > <sean.dewol...@nospamplease.umit.maine.edu> wrote:
> > > i2000s <e20...@gmail.com> wrote in message <d3226a15-d1c6-4a0c-a6b1-997be6fda...@i18g2000yqn.googlegroups.com>...
> > > > Hi there,
>
> > > > I am trying to generate a 8n*4 array basing on a n*4 array. The n*4
> > > > array is a data base describe a physical parameter E(x, y, z) in a
> > > > quadrant, with every row in the format (x, ,y, z, E), and (x, y, z) is
> > > > the coordinate of the parameter. Along with the coordinate changing,
> > > > this array gives n rows to describe the E parameter in n places in the
> > > > first quadrant of space. And the 8n*4 array is just the mirror array
> > > > in full space with a symmetric or anti-symmetric value E to the first
> > > > quadrant.  For example, if in x-axis the E is symmetric, so when x'<0,
> > > > E(x')=E(x) with x=-x'>0, when x'=x=0, E(x')=E(x); if in x-axis E is
> > > > anti symmetric, E(x')=-E(x) and E(0)=0. I can generate the E(x) in one
> > > > dimension, while this problem is not so easy, because we have three
> > > > coordinate indexes to label the E in full space. And my final goal is
> > > > get the full space parameter value array only basing on the first
> > > > quadrant value array.
>
> > > > Any help?
>
> > > > My code doesn't work ...
> > > > Thanks.
>
> > > > Best wishes,
> > > > Q
>
> > > Show us the code you've tried!
>
> > > And more importantly, show us a (small) example of input/rules/output; perhaps n=3?
>
> > If I have to post my code, then I have to:
> > Correct the size of the reference array is wrong. In the array it
> > stores data in the form of A=(x, y, z, E) with xn*ym*zp space points,
> > where xn is the index number of x (definitely include 0) and so on,
> > and E has three components, so it has a size  (xn, ym, zp, 3). And
> > another problem is I don't know whether the original array is in the
> > first quadrant: x,y,z are all set to symmetric/anti-symmetric, then A
> > is in the first quadrant; only two of x,y,z are set to symmetric/anti-
> > symmetric, then A is within two quadrant; if only one of x,y,z is set
> > to symmetric then A is within 4 quadrant; if none coordinate is
> > symmetric/anti-symmetric then A is in full space (do not need to
> > unwrap).
>
> > My code gives:
>
> > ----------------------
> > Unwrap2FullSpace.m
> > ----------------------
> > % input A and the symmetric index sym
> > n=100;m=101;p=102;
> > A=rand(n,m,p,1);      %random mode data
> > Ex0=A;                    % for Ex component of E.
> > Ey0=A+1;
> > Ez0=A+2;
> > sym=[1,0,-1];      %symmetric setting for the data;1 means symmetric
> > setting,
> >                   % 0 no symmetric setting, -1 anti-symmetric setting
> > in corresponding entry
> > a=abs(sym);       %parameter to judge whether it uses symmetric
> > setting
> > ft=sum(a);        % unwrapped times
> > sizemode=[n m p];
>
> > % flipping the data
> > E=zeros(size(Ex0,1)*(1+a(1)),size(Ex0,2)*(1+a(2)),size(Ex0,3)*(1+a(3)),
> > 3); % only consider Ex
> > label={'x','y','z'};
> > E(1:sizemode(1),1:sizemode(2),1:sizemode(3),1)=Ex0;
> > E(1:sizemode(1),1:sizemode(2),1:sizemode(3),2)=Ey0;
> > E(1:sizemode(1),1:sizemode(2),1:sizemode(3),3)=Ez0;
>
> > % only works for 3-D matrices without singlon
> > for ii=1:3
> >     if a(ii)==1
> >         E1=zeros(sizemode);
> >         E1(:,:,:)=squeeze(E(:,:,:,1)); %size mismatch
> >         E1=shiftdim(E1,ii);
> >         E1(1:sizemode(ii),:,:)=E1(sizemode(ii):-1:1,:,:);
> >         E1=shiftdim(E1,-ii);
> >         E1=flipdim(E1,ii);
> >         E(:,:,:,1)=squeeze(E(:,:,:,1))+sym(ii)*E1;
>
> >         E2=zeros(sizemode);
> >         E2(:,:,:)=squeeze(E(:,:,:,2));
> >         E2=shiftdim(E2,ii);
> >         E2(1:sizemode(ii),:,:)=E2(sizemode(ii):-1:1,:,:);
> >         E2=shiftdim(E2,-ii);
> >         E2=flipdim(E2,ii);
> >         E(:,:,:,2)=squeeze(E(:,:,:,2))+sym(ii)*E2;
>
> >         E3=zeros(sizemode);
> >         E3(:,:,:)=squeeze(E(:,:,:,3));
> >         E3=shiftdim(E3,ii);
> >         E3(1:sizemode(ii),:,:)=E3(sizemode(ii):-1:1,:,:);
> >         E3=shiftdim(E3,-ii);
> >         E3=flipdim(E3,ii);
> >         E(:,:,:,3)=squeeze(E(:,:,:,3))+sym(ii)*E3;
>
> >     end % flipping the data
> > end     % counting dimenssion
>
> > % check the spatial symmetry for the unwrpped data
> > figure;
> > imagesc(squeeze(E(:,50,:,1)));
> > figure;
> > imagesc(squeeze(E(:,:,50,1)));
> > figure;
> > imagesc(squeeze(E(50,:,:,1)));
> > ____________________________________
>
> > Problems:
> > 1. dimension dismatch;
> > 2. cannot exclude the duplicated data for x,y,z=0.
> > ...
>
> > Thanks.
>
> I would like to give an example on 2D space's case:
> If at the first quadrant, we have
> A=[ 1 2 3;
>     4 5 6;
>     7 8 9]
> with x-symmetry and y-anti-symmetry in full 2D space, then I expect to
> get
> E=[ 3  2  1  2  3;
>     6  5  4  5  6;
>     9  8  7  8  9;
>    -9 -8 -7 -8 -9;
>    -6 -5 -4 -5 -6;
>    -3 -2 -1 -2 -3].
> If it is in 3D space, then in z-axis, I also need to consider
> expanding the size, if possible.
>
> This problem just ask for an unfolding on 3D space but I have to judge
> which dimension is set to be symmetric or anti-symmetric.
>
> Have I make it clear?
>
> Best wishes,
> Q

Sorry, the E above should be:
 % -x2 -x1 0 x1 x2
E=[ 3 2 1 2 3; %y2
    6 5 4 5 6; %y1
    9 8 7 8 9; %y=0
   -6 -5 -4 -5 -6; %-y1
   -3 -2 -1 -2 -3].%-y2
since y=0 is the center...

Subject: How to generate a full space array basing on the first quadrant's

From: Steven_Lord

Date: 5 Jan, 2011 14:50:21

Message: 6 of 6



"i2000s" <e2000s@gmail.com> wrote in message
news:564d0a6f-8adb-44f3-8ee5-3a7ae3dbf301@o4g2000yqd.googlegroups.com...
> On Jan 4, 10:47 pm, i2000s <e20...@gmail.com> wrote:

*snip*

>> I would like to give an example on 2D space's case:
>> If at the first quadrant, we have
>> A=[ 1 2 3;
>> 4 5 6;
>> 7 8 9]
>> with x-symmetry and y-anti-symmetry in full 2D space, then I expect to
>> get
>> E=[ 3 2 1 2 3;
>> 6 5 4 5 6;
>> 9 8 7 8 9;
>> -9 -8 -7 -8 -9;
>> -6 -5 -4 -5 -6;
>> -3 -2 -1 -2 -3].
>> If it is in 3D space, then in z-axis, I also need to consider
>> expanding the size, if possible.
>>
>> This problem just ask for an unfolding on 3D space but I have to judge
>> which dimension is set to be symmetric or anti-symmetric.
>>
>> Have I make it clear?
>>
>> Best wishes,
>> Q
>
> Sorry, the E above should be:
> % -x2 -x1 0 x1 x2
> E=[ 3 2 1 2 3; %y2
> 6 5 4 5 6; %y1
> 9 8 7 8 9; %y=0
> -6 -5 -4 -5 -6; %-y1
> -3 -2 -1 -2 -3].%-y2
> since y=0 is the center...

A = [1 2 3; 4 5 6;7 8 9];
isSymX = 1;
isSymY = -1;
E1 = [isSymX*A(:, end:-1:2), A];
E = [E1; isSymY*E1(end-1:-1:1, :)]

For N-D you will need to use the CAT function.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlab.wikia.com/wiki/FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

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