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:
error message : Assignment has more non-singleton rhs dimensions than non-singleton

Subject: error message : Assignment has more non-singleton rhs dimensions than non-singleton

From: adinda

Date: 22 May, 2006 14:07:30

Message: 1 of 2

This is a really strange problem..;to me at least

I have the following two programs


feature accel off
%instellen parameters
global d
d=5; %breedte, hoogte golfgeleider
l=10*d; %lengte golfgeleider
c=340; %geluidsnelheid
CN=1; %Courant getal stabiel systeem
ts=300;%aantal stappen
vf=3; %verfijningsfactor

%discretisatie
dx=d/10; dy=dx; dz=dx; %volgens figuur bij de opdracht
dt=CN/(c*sqrt((1/dx^2)+(1/dy^2)+(1/dz^2))); %tijdstap met
stabiliteitsvoorwaarde
%verfijnd grid
dxf=dx/vf; dyf=dxf; dzf=dxf;


dtf=dt/vf; %verfijnde tijdstap

%aantal cellen
cx=l/dx+d/dx; cy=d/dy; cz=d/dz+l/dz; %verduidelijking op figuur in
verslag

%bronpuls, fq<51 via voor waarde k*d=1,5*pi
A=1; fq=25; t0=2.5*10^-2; s=2*10^(-5);

%plaats bron (niet op de golfgeleider anders werkt programma
niet)(xb=0)
xb=1; yb=round(d/2/dy); zb=round(d/2/dz);



%waarnemingen bocht
xwb1=cx-10;ywb1=yb; zwb1=zb;
xwb2=cx-round(d/2);ywb2=yb; zwb2=zb+10;

%snelheid & druk
global ox oy oz p
ox = zeros(cx+1, cy, cz); oy = zeros(cx, cy+1, cz); oz = zeros(cx, cy,
cz+1); p = zeros(cx, cy, cz);

%verfijning rooster
global oxf oyf ozf pf
cxf=d/dxf+2*floor(vf/2);
cyf=d/dyf+2*floor(vf/2);
czf=d/dzf+2*floor(vf/2);
oxf = zeros(cxf+1, cyf, czf);
oyf= zeros(cxf, cyf+1, czf);
ozf = zeros(cxf, cyf, czf+1);
pf = zeros(cxf, cyf, czf);

%schuin bochtstuk verfijning van de matrix
global Mf
m=d/dxf+1; M=zeros(m,m);
%vakje binnen/buiten bochtstuk
for i=1:m
         for j=1:m
                  z1=(i-1)*dzf ;
                  x1=(j-1)*dxf ;
                  if (((z1==d) & 0<=x1<=d)|((x1==0) & 0<=z1<=d))
                      Mf(i,j)=1; %als de cellen in de doorsnede
liggen=1

                  end
                  if (dzf<=z1<=d)
                      if (0<=x1<=d-dxf)
                          if(x1<=z1)
                             Mf(i,j)=1;

                          end
                      end
                  end
         end
end



reg1 = zeros(ts,1); %registratie 1
reg2 = zeros(ts,1); %registratie 2

T=zeros(ts,1); %tijdstappen
B=0;
anim=moviein(ts);

for ti=1:ts
            T(ti)=(ti-1)*dtf;

            %numerieke waarden omzetten in string
            disp([num2str(ti) '/' num2str(ts)]);

            %bronpuls

            B=A*sin(2*pi*fq*(T(ti)-t0))*exp(-((T(ti)-t0))^2/s);
            % geen puntbron meer, maar een vlak als bron
            for kb=1:d/dz
               for jb=1:cy
               p(xb,jb,kb) = p(xb,jb,kb)+B;
               end
            end



            %propagatie in 1 tijdstap
            fdtdschuinfijn2(cx,cy,cz,c,dx,dy,dz,dxf,dyf,dzf,dt,dtf)

            %druk registreren

            reg1(ti) = p(xwb1,ywb1,zwb1);
            reg2(ti) = p(xwb2,ywb2,zwb2);
            %vlak // met XZ vlak
            vlak=zeros(cx,cz);
            for i=1:cx
                        for j=1:cz
                        vlak(i,j)=p(i,cy/2+1,j);
                        end
            end

            %animatie
            surf(vlak);
            shading interp;
            view(90,90)
            axis equal;
            caxis([-0.01*A 0.01*A]);
            title([num2str(ti) ' of ' num2str(ts)]);
            hold on;
            xlim([1 cz]);
            ylim([1 cx]);
            plot(zb,xb,'ro');

            plot(zwb1,xwb1,'ro','MarkerFaceColor' ,'y');
            plot(zwb2,xwb2,'ro','MarkerFaceColor' ,'y');
            hold off;
            anim(ti) = getframe;
end


f=linspace(0,1/dt,ts);
for i=1:ts
    if (f(i)<=c*1.5/2/d)
        m=i;
    end
end
Intensity_mean=ones(1,ts);
vermogenschuin=ones(1,ts);

Intensity_mean=(-1./(2.*pi.*f.*dx)).*(imag((conj(fft(reg1'))).*(fft(reg2'))));
for i=1:ts
    vermogenschuin(1,i)=Intensity_mean(1,i);
end

%plotjes

figure;
xlim([c/(15*d) c/(1.5*d)]);
plot(f(1:m),vermogenschuin(1:m))
xlabel('frequentie in Hz')
title('waarneming bochtstuk')


function fdtdschuinfijn2(cx,cy,cz,c,dx,dy,dz,dxf,dyf,dzf,dt,dtf)
global ox oy oz p Mf d vf oxf oyf ozf

%berekening van p's
%golfgeleider
for i=1:cx-d/dx
          for j=1:cy
                     for k=1:d/dz
                         for u=1:d/dy
                             for v=1:d/dz
                                 if (i==cx-d/dx & j==u & k==v)%vlak
links

p(i,j,k)=p(i,j,k)-c^2*dtf*((oxf(floor(vf/2)+1,floor(vf/2)+(u-1)*vf+ceil(vf/2),floor(vf/2)+(v-1)*vf+ceil(vf/2))-ox(i,j,k))/dx+(oy(i,j+1,k)-oy(i,j,k))/dy+(oz(i,j,k+1)-oz(i,j,k))/dz);
                    else

p(i,j,k)=p(i,j,k)-c^2*dtf*((ox(i+1,j,k)-ox(i,j,k))/dx+(oy(i,j+1,k)-oy(i,j,k))/dy+(oz(i,j,k+1)-oz(i,j,k))/dz);
                                 end
                             end
                         end


                     end
          end
end
% plaats bocht in geheel
gx=cx-d/dx;
gz=1;
%verfijnd bochtstuk
for i=1:size(pf,1)
                  for j=1:size(pf,2)
                                   for k=1:size(pf,3)

pf(i,j,k)=pf(i,j,k)-c^2*dtf*((oxf(i+1,j,k)-oxf(i,j,k))/dxf+(oyf(i,j+1,k)-oyf(i,j,k))/dyf+(ozf(i,j,k+1)-ozf(i,j,k))/dzf)*Mf(k-gz+1,i-gx);
                                   end
                  end
end





%tweede deel geleider
for i=cx-d/dx+1:cx
                   for j=1:cy
                             for k=d/dz+1:cz
                                 for u=1:d/dx
                                                for v=1:d/dy
                                                               if
(k==d/dz+1 & i==cx-d/dx+u & j==v)%vlak onder bocht

p(i,j,k)=p(i,j,k)-c^2*dtf*((ox(i,j,k+1)-ox(i,j,k))/dx+(oy(i,j+1,k)-oy(i,j,k))/dy+(oz(i,j,k+1)-ozf(floor(vf/2)+(u-1)*vf+ceil(vf/2),floor(vf/2)+(v-1)*vf+ceil(vf/2),k+floor(vf/2)+1))/dz);
                                                               else

p(i,j,k)=p(i,j,k)-c^2*dtf*((ox(i+1,j,k)-ox(i,j,k))/dx+(oy(i,j+1,k)-oy(i,j,k))/dy+(oz(i,j,k+1)-oz(i,j,k))/dz);
                                                               end
                                                 end
                                 end

                             end
                   end
end



%berekening van de o's
%golfgeleider
for i=2:cx-d/dx
            for j=1:cy
                      for k=1:d/dz
                      ox(i,j,k)=ox(i,j,k)-dtf/dx*(p(i,j,k)-p(i-1,j,k));

                      end
            end
end

for i=1:cx-d/dx
            for j=2:cy
                      for k=1:d/dz
                      oy(i,j,k)=oy(i,j,k)-dtf/dy*(p(i,j,k)-p(i,j-1,k));

                      end
            end
end

for i=1:cx-d/dx
            for j=1:cy
                      for k=2:d/dz
                      oz(i,j,k)=oz(i,j,k)-dtf/dz*(p(i,j,k)-p(i,j,k-1));

                      end
            end
end
% voor het vlak links van de bocht en het vlak onder de bocht aparte
% matrices in rekening brengen
%de drukken worden overgenomen uit het eerste grid als ze dezelfde
positie
%innemen, anders worden ze via interpolatie berekend

%vlak links van de bocht
m1=zeros(size(pf,2),size(pf,3));
for j=1:size(pf,2)
    for k=1:size(pf,3)
        if (mod(j,vf)==1 & mod(k,vf)==1)
            m1(j,k)=p(cx-d/dx,d/dy+floor(j/vf),1+floor(k/vf));
        end
    end
end
for j=1:size(m1,1)
    for k=1:size(m1,2)
        p1=m1(j,k-mod(k-1,vf));
        p2=m1(j,k-mod(k-1,vf)+vf);
        p3=m1(j-mod(j-1,vf),k);
        p4=m1(j-mod(j-1,vf)+vf,k);
        % rijen invullen
        if (mod(j,vf)==1) & (mod(k,vf)~=1)
            m1(j,k)=p1+(p2-p1)*mod(k-1,vf)/vf;

        % kolommen invullen
        else if (mod(k,vf)==1) & (mod(j,vf)~=1)
            m1(j,k)=p3+(p4-p3)*mod(j-1,vf)/vf;
            end
        end
        % tussenliggende elementen
            if (mod(j,vf)~=1) & (mod(k,vf)~=1)
                p5=p1+(p2-p1)*mod(k-1,vf)/vf;
                p6=p3+(p4-p3)*mod(j-1,vf)/vf;
                m1(j,k)=(p5+p6)/2;
            end

    end
end

%vlak onder de bocht
m2=zeros(size(pf,1),size(pf,2));
for i=1:size(pf,1)
    for j=1:size(pf,2)
        if (mod(i,vf)==1 & mod(j,vf)==1)
            m2(i,j)=p(cx-d/dx+floor(i/vf),1+floor(j/vf),d/dz);
        end
    end
end
for i=1:size(m2,1)
    for j=1:size(m2,2)
        p1=m1(i,j-mod(j-1,vf));
        p2=m1(i,j-mod(j-1,vf)+vf);
        p3=m1(i-mod(i-1,vf),j);
        p4=m1(i-mod(i-1,vf)+vf,j);
        % rijen invullen
        if (mod(i,vf)==1) & (mod(j,vf)~=1)
            m2(i,j)=p1+(p2-p1)*mod(j-1,vf)/vf;

        % kolommen invullen
        else if (mod(j,vf)==1) & (mod(i,vf)~=1)
            m2(i,j)=p3+(p4-p3)*mod(i-1,vf)/vf;
            end
        end
        % tussenliggende elementen
            if (mod(i,vf)~=1) & (mod(j,vf)~=1)
                p5=p1+(p2-p1)*mod(j-1,vf)/vf;
                p6=p3+(p4-p3)*mod(i-1,vf)/vf;
                m2(j,k)=(p5+p6)/2;
            end

    end
end


%bochtstuk
for i=cx-d/dx+1:cx
                  for j=1:cy
                            for k=1:d/dz
                                if (i==cx-d/dx+1)%vlak links van bocht
                                    oxf(i,j,k) = (oxf(i,j,k) -
dtf/dxf*(pf(i,j,k) - m1(j+1,k+1)));

                                else

oxf(i,j,k)=(oxf(i,j,k)-dtf/dxf*(pf(i,j,k)-pf(i-1,j,k)));
                                end
                            end
                  end
end

for i=cx-d/dx+1:cx
                  for j=2:cy
                            for k=1:d/dz
                            oyf(i,j,k) =
(oyf(i,j,k)-dtf/dyf*(pf(i,j,k)-pf(i,j-1,k)))*Mf(k-gz+1,i-gx);
                            end
                  end
end

for i=cx-d/dx+1:cx
                  for j=1:cy
                            for k=2:d/dz
                                if (k==d/dz)
                                    ozf(i,j,k) = (ozf(i,j,k) -
dtf/dzf*(m2(i+1,j+1) - pf(i,j,k-1)));
                                else
                                    ozf(i,j,k) =
(ozf(i,j,k)-dtf/dzf*(pf(i,j,k)- pf(i,j,k-1)));
                                end
                            end
                  end
end

%tweede deel golfgeleider
for i=cx-d/dx+1:cx
            for j=1:cy
                      for k=d/dz+1:cz
                      ox(i,j,k)=ox(i,j,k)-dtf/dx*(p(i,j,k)-p(i-1,j,k));

                      end
            end
end

for i=cx-d/dx+1:cx
            for j=2:cy
                      for k=d/dz+1:cz
                      oy(i,j,k)=oy(i,j,k)-dtf/dy*(p(i,j,k)-p(i,j-1,k));

                      end
            end
end

for i=cx-d/dx+1:cx
            for j=1:cy
                      for k=d/dz+1:cz
                      oz(i,j,k)=oz(i,j,k)-dtf/dz*(p(i,j,k)-p(i,j,k-1));

                      end
            end
end


%absorberende wanden

for j=1:cy
           for k=1:d/dz

ox(1,j,k)=(1-c/vf*dtf/dx)/(1+c/vf*dtf/dx)*ox(1,j,k)-(2*dtf/dx)/(1+c/vf*dtf/dx)*p(1,j,k);
 %links



       end
end

for i=cx-d/dx:cx
    for j=1:cy

oz(i,j,cz+1)=(1-c/vf*dtf/dz)/(1+c/vf*dt/dz)*oz(i,j,cz+1)+(2*dtf/dz)/(1+c/vf*dtf/dz)*p(i,j,cz);%onderaan
    end
end



in line 12 of the second program (fdtdschuin2) lies the problem...well
that's as far as it'll go anyway...and here i was thinking i was just
adding and subtracting numbers from other numbers....PLEASE HELP i've
been busting my head over this for days...

Subject: error message : Assignment has more

From: BJ Schubert

Date: 23 Jun, 2006 16:26:09

Message: 2 of 2

adinda wrote:
>
>
> This is a really strange problem..;to me at least
>
> I have the following two programs
>
>
> feature accel off
> %instellen parameters
> global d
> d=5; %breedte, hoogte golfgeleider
> l=10*d; %lengte golfgeleider
> c=340; %geluidsnelheid
> CN=1; %Courant getal stabiel systeem
> ts=300;%aantal stappen
> vf=3; %verfijningsfactor
>
> %discretisatie
> dx=d/10; dy=dx; dz=dx; %volgens figuur bij de opdracht
> dt=CN/(c*sqrt((1/dx^2)+(1/dy^2)+(1/dz^2))); %tijdstap met
> stabiliteitsvoorwaarde
> %verfijnd grid
> dxf=dx/vf; dyf=dxf; dzf=dxf;
>
>
> dtf=dt/vf; %verfijnde tijdstap
>
> %aantal cellen
> cx=l/dx+d/dx; cy=d/dy; cz=d/dz+l/dz; %verduidelijking op figuur in
> verslag
>
> %bronpuls, fq<51 via voor waarde k*d=1,5*pi
> A=1; fq=25; t0=2.5*10^-2; s=2*10^(-5);
>
> %plaats bron (niet op de golfgeleider anders werkt programma
> niet)(xb=0)
> xb=1; yb=round(d/2/dy); zb=round(d/2/dz);
>
>
>
> %waarnemingen bocht
> xwb1=cx-10;ywb1=yb; zwb1=zb;
> xwb2=cx-round(d/2);ywb2=yb; zwb2=zb+10;
>
> %snelheid & druk
> global ox oy oz p
> ox = zeros(cx+1, cy, cz); oy = zeros(cx, cy+1, cz); oz = zeros(cx,
> cy,
> cz+1); p = zeros(cx, cy, cz);
>
> %verfijning rooster
> global oxf oyf ozf pf
> cxf=d/dxf+2*floor(vf/2);
> cyf=d/dyf+2*floor(vf/2);
> czf=d/dzf+2*floor(vf/2);
> oxf = zeros(cxf+1, cyf, czf);
> oyf= zeros(cxf, cyf+1, czf);
> ozf = zeros(cxf, cyf, czf+1);
> pf = zeros(cxf, cyf, czf);
>
> %schuin bochtstuk verfijning van de matrix
> global Mf
> m=d/dxf+1; M=zeros(m,m);
> %vakje binnen/buiten bochtstuk
> for i=1:m
> for j=1:m
> z1=(i-1)*dzf ;
> x1=(j-1)*dxf ;
> if (((z1==d) & 0<=x1<=d)|((x1==0) & 0<=z1<=d))
> Mf(i,j)=1; %als de cellen in de doorsnede
> liggen=1
>
> end
> if (dzf<=z1<=d)
> if (0<=x1<=d-dxf)
> if(x1<=z1)
> Mf(i,j)=1;
>
> end
> end
> end
> end
> end
>
>
>
> reg1 = zeros(ts,1); %registratie 1
> reg2 = zeros(ts,1); %registratie 2
>
> T=zeros(ts,1); %tijdstappen
> B=0;
> anim=moviein(ts);
>
> for ti=1:ts
> T(ti)=(ti-1)*dtf;
>
> %numerieke waarden omzetten in string
> disp([num2str(ti) '/' num2str(ts)]);
>
> %bronpuls
>
> B=A*sin(2*pi*fq*(T(ti)-t0))*exp(-((T(ti)-t0))^2/s);
> % geen puntbron meer, maar een vlak als bron
> for kb=1:d/dz
> for jb=1:cy
> p(xb,jb,kb) = p(xb,jb,kb)+B;
> end
> end
>
>
>
> %propagatie in 1 tijdstap
> fdtdschuinfijn2(cx,cy,cz,c,dx,dy,dz,dxf,dyf,dzf,dt,dtf)
>
> %druk registreren
>
> reg1(ti) = p(xwb1,ywb1,zwb1);
> reg2(ti) = p(xwb2,ywb2,zwb2);
> %vlak // met XZ vlak
> vlak=zeros(cx,cz);
> for i=1:cx
> for j=1:cz
> vlak(i,j)=p(i,cy/2+1,j);
> end
> end
>
> %animatie
> surf(vlak);
> shading interp;
> view(90,90)
> axis equal;
> caxis([-0.01*A 0.01*A]);
> title([num2str(ti) ' of ' num2str(ts)]);
> hold on;
> xlim([1 cz]);
> ylim([1 cx]);
> plot(zb,xb,'ro');
>
> plot(zwb1,xwb1,'ro','MarkerFaceColor' ,'y');
> plot(zwb2,xwb2,'ro','MarkerFaceColor' ,'y');
> hold off;
> anim(ti) = getframe;
> end
>
>
> f=linspace(0,1/dt,ts);
> for i=1:ts
> if (f(i)<=c*1.5/2/d)
> m=i;
> end
> end
> Intensity_mean=ones(1,ts);
> vermogenschuin=ones(1,ts);
>
>
Intensity_mean=(-1./(2.*pi.*f.*dx)).*(imag((conj(fft(reg1'))).*(fft(
> reg2'))));
> for i=1:ts
> vermogenschuin(1,i)=Intensity_mean(1,i);
> end
>
> %plotjes
>
> figure;
> xlim([c/(15*d) c/(1.5*d)]);
> plot(f(1:m),vermogenschuin(1:m))
> xlabel('frequentie in Hz')
> title('waarneming bochtstuk')
>
>
> function fdtdschuinfijn2(cx,cy,cz,c,dx,dy,dz,dxf,dyf,dzf,dt,dtf)
> global ox oy oz p Mf d vf oxf oyf ozf
>
> %berekening van p's
> %golfgeleider
> for i=1:cx-d/dx
> for j=1:cy
> for k=1:d/dz
> for u=1:d/dy
> for v=1:d/dz
> if (i==cx-d/dx & j==u & k==v)%vlak
> links
>
>
p(i,j,k)=p(i,j,k)-c^2*dtf*((oxf(floor(vf/2)+1,floor(vf/2)+(u-1)*vf+c
>
eil(vf/2),floor(vf/2)+(v-1)*vf+ceil(vf/2))-ox(i,j,k))/dx+(oy(i,j+1,k
> )-oy(i,j,k))/dy+(oz(i,j,k+1)-oz(i,j,k))/dz);
> else
>
>
p(i,j,k)=p(i,j,k)-c^2*dtf*((ox(i+1,j,k)-ox(i,j,k))/dx+(oy(i,j+1,k)-o
> y(i,j,k))/dy+(oz(i,j,k+1)-oz(i,j,k))/dz);
> end
> end
> end
>
>
> end
> end
> end
> % plaats bocht in geheel
> gx=cx-d/dx;
> gz=1;
> %verfijnd bochtstuk
> for i=1:size(pf,1)
> for j=1:size(pf,2)
> for k=1:size(pf,3)
>
>
pf(i,j,k)=pf(i,j,k)-c^2*dtf*((oxf(i+1,j,k)-oxf(i,j,k))/dxf+(oyf(i,j+
>
1,k)-oyf(i,j,k))/dyf+(ozf(i,j,k+1)-ozf(i,j,k))/dzf)*Mf(k-gz+1,i-gx);
>
> end
> end
> end
>
>
>
>
>
> %tweede deel geleider
> for i=cx-d/dx+1:cx
> for j=1:cy
> for k=d/dz+1:cz
> for u=1:d/dx
> for v=1:d/dy
> if
> (k==d/dz+1 & i==cx-d/dx+u & j==v)%vlak onder bocht
>
>
p(i,j,k)=p(i,j,k)-c^2*dtf*((ox(i,j,k+1)-ox(i,j,k))/dx+(oy(i,j+1,k)-o
>
y(i,j,k))/dy+(oz(i,j,k+1)-ozf(floor(vf/2)+(u-1)*vf+ceil(vf/2),floor(
> vf/2)+(v-1)*vf+ceil(vf/2),k+floor(vf/2)+1))/dz);
> else
>
>
p(i,j,k)=p(i,j,k)-c^2*dtf*((ox(i+1,j,k)-ox(i,j,k))/dx+(oy(i,j+1,k)-o
> y(i,j,k))/dy+(oz(i,j,k+1)-oz(i,j,k))/dz);
> end
> end
> end
>
> end
> end
> end
>
>
>
> %berekening van de o's
> %golfgeleider
> for i=2:cx-d/dx
> for j=1:cy
> for k=1:d/dz
>
> ox(i,j,k)=ox(i,j,k)-dtf/dx*(p(i,j,k)-p(i-1,j,k));
>
> end
> end
> end
>
> for i=1:cx-d/dx
> for j=2:cy
> for k=1:d/dz
>
> oy(i,j,k)=oy(i,j,k)-dtf/dy*(p(i,j,k)-p(i,j-1,k));
>
> end
> end
> end
>
> for i=1:cx-d/dx
> for j=1:cy
> for k=2:d/dz
>
> oz(i,j,k)=oz(i,j,k)-dtf/dz*(p(i,j,k)-p(i,j,k-1));
>
> end
> end
> end
> % voor het vlak links van de bocht en het vlak onder de bocht
> aparte
> % matrices in rekening brengen
> %de drukken worden overgenomen uit het eerste grid als ze dezelfde
> positie
> %innemen, anders worden ze via interpolatie berekend
>
> %vlak links van de bocht
> m1=zeros(size(pf,2),size(pf,3));
> for j=1:size(pf,2)
> for k=1:size(pf,3)
> if (mod(j,vf)==1 & mod(k,vf)==1)
> m1(j,k)=p(cx-d/dx,d/dy+floor(j/vf),1+floor(k/vf));
> end
> end
> end
> for j=1:size(m1,1)
> for k=1:size(m1,2)
> p1=m1(j,k-mod(k-1,vf));
> p2=m1(j,k-mod(k-1,vf)+vf);
> p3=m1(j-mod(j-1,vf),k);
> p4=m1(j-mod(j-1,vf)+vf,k);
> % rijen invullen
> if (mod(j,vf)==1) & (mod(k,vf)~=1)
> m1(j,k)=p1+(p2-p1)*mod(k-1,vf)/vf;
>
> % kolommen invullen
> else if (mod(k,vf)==1) & (mod(j,vf)~=1)
> m1(j,k)=p3+(p4-p3)*mod(j-1,vf)/vf;
> end
> end
> % tussenliggende elementen
> if (mod(j,vf)~=1) & (mod(k,vf)~=1)
> p5=p1+(p2-p1)*mod(k-1,vf)/vf;
> p6=p3+(p4-p3)*mod(j-1,vf)/vf;
> m1(j,k)=(p5+p6)/2;
> end
>
> end
> end
>
> %vlak onder de bocht
> m2=zeros(size(pf,1),size(pf,2));
> for i=1:size(pf,1)
> for j=1:size(pf,2)
> if (mod(i,vf)==1 & mod(j,vf)==1)
> m2(i,j)=p(cx-d/dx+floor(i/vf),1+floor(j/vf),d/dz);
> end
> end
> end
> for i=1:size(m2,1)
> for j=1:size(m2,2)
> p1=m1(i,j-mod(j-1,vf));
> p2=m1(i,j-mod(j-1,vf)+vf);
> p3=m1(i-mod(i-1,vf),j);
> p4=m1(i-mod(i-1,vf)+vf,j);
> % rijen invullen
> if (mod(i,vf)==1) & (mod(j,vf)~=1)
> m2(i,j)=p1+(p2-p1)*mod(j-1,vf)/vf;
>
> % kolommen invullen
> else if (mod(j,vf)==1) & (mod(i,vf)~=1)
> m2(i,j)=p3+(p4-p3)*mod(i-1,vf)/vf;
> end
> end
> % tussenliggende elementen
> if (mod(i,vf)~=1) & (mod(j,vf)~=1)
> p5=p1+(p2-p1)*mod(j-1,vf)/vf;
> p6=p3+(p4-p3)*mod(i-1,vf)/vf;
> m2(j,k)=(p5+p6)/2;
> end
>
> end
> end
>
>
> %bochtstuk
> for i=cx-d/dx+1:cx
> for j=1:cy
> for k=1:d/dz
> if (i==cx-d/dx+1)%vlak links van
> bocht
> oxf(i,j,k) = (oxf(i,j,k) -
> dtf/dxf*(pf(i,j,k) - m1(j+1,k+1)));
>
> else
>
> oxf(i,j,k)=(oxf(i,j,k)-dtf/dxf*(pf(i,j,k)-pf(i-1,j,k)));
> end
> end
> end
> end
>
> for i=cx-d/dx+1:cx
> for j=2:cy
> for k=1:d/dz
> oyf(i,j,k) =
> (oyf(i,j,k)-dtf/dyf*(pf(i,j,k)-pf(i,j-1,k)))*Mf(k-gz+1,i-gx);
> end
> end
> end
>
> for i=cx-d/dx+1:cx
> for j=1:cy
> for k=2:d/dz
> if (k==d/dz)
> ozf(i,j,k) = (ozf(i,j,k) -
> dtf/dzf*(m2(i+1,j+1) - pf(i,j,k-1)));
> else
> ozf(i,j,k) =
> (ozf(i,j,k)-dtf/dzf*(pf(i,j,k)- pf(i,j,k-1)));
> end
> end
> end
> end
>
> %tweede deel golfgeleider
> for i=cx-d/dx+1:cx
> for j=1:cy
> for k=d/dz+1:cz
>
> ox(i,j,k)=ox(i,j,k)-dtf/dx*(p(i,j,k)-p(i-1,j,k));
>
> end
> end
> end
>
> for i=cx-d/dx+1:cx
> for j=2:cy
> for k=d/dz+1:cz
>
> oy(i,j,k)=oy(i,j,k)-dtf/dy*(p(i,j,k)-p(i,j-1,k));
>
> end
> end
> end
>
> for i=cx-d/dx+1:cx
> for j=1:cy
> for k=d/dz+1:cz
>
> oz(i,j,k)=oz(i,j,k)-dtf/dz*(p(i,j,k)-p(i,j,k-1));
>
> end
> end
> end
>
>
> %absorberende wanden
>
> for j=1:cy
> for k=1:d/dz
>
>
ox(1,j,k)=(1-c/vf*dtf/dx)/(1+c/vf*dtf/dx)*ox(1,j,k)-(2*dtf/dx)/(1+c/
> vf*dtf/dx)*p(1,j,k);
> %links
>
>
>
> end
> end
>
> for i=cx-d/dx:cx
> for j=1:cy
>
>
oz(i,j,cz+1)=(1-c/vf*dtf/dz)/(1+c/vf*dt/dz)*oz(i,j,cz+1)+(2*dtf/dz)/
> (1+c/vf*dtf/dz)*p(i,j,cz);%onderaan
> end
> end
>
>
>
> in line 12 of the second program (fdtdschuin2) lies the
> problem...well
> that's as far as it'll go anyway...and here i was thinking i was
> just
> adding and subtracting numbers from other numbers....PLEASE HELP
> i've
> been busting my head over this for days...
>
>
  

I was getting the same error message. My problem was that I was
trying to write a three dimensional array to a variable which had
already been defined as a one dimensional array. Clearing the
variable and then trying again solved my problem
>> clear i
%where i was the name of my variable

Another problem I was having was with the dimensions of the arrays I
was trying to save to my three dimensional array were different.
This was giving me a similar error message. Example: I was saving a
two dimensional array to a three dimensional array, the dimensions of
the first two dimensional array were 38x7 and of the second were
33x7. MatLab didn't like this one bit.

>> A(:,:,1)=[1,2,3;3,4,5]
A =
     1 2 3
     3 4 5
>> A(:,:,2)=[5,6,7;7,8,9]
A(:,:,1) =
     1 2 3
     3 4 5
A(:,:,2) =
     5 6 7
     7 8 9
>> A(:,:,3)=[3,4,5]
??? Subscripted assignment dimension mismatch.

I think I was getting the non-singleton message before when I did
this but I am not having success replicating it.

Hope this helps.

BJ

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