MATLAB Answers

0

Subscription assignment dimension mismatch.

Asked by sriram amarnath on 29 Jul 2019
Latest activity Answered by Navya Seelam on 6 Aug 2019
Lx=0.286; % length of plate(m)
Lz=0.198; % breadth of plate(m)
F=1;% Point load assumed to be 1 newton @ (x0,z0)
Y=1.4e9 ;%Youngs modulus
sigma=0.3;%Poissons ratio
eta=4e-2;%Damping Factor
D=Y*d^3/(12*(1-sigma^2));% flexural density D eq 86 Notes
d=3.25e-3;% thickness of plate(m)(also h)
rowS=265*d;%Mass per unit area( M surface density)
m=1:1000;% mode numbers width
nmax=10; % mode numbers length
t=1; % time
x0=0.16;%exc=(0.16,0.083), point of excitation(m)
z0=0.083;%exc=(0.16,0.083), point of excitation(m)
xr=linspace(0,Lx,10);% 10 x co-ordinate points on surface
zr=linspace(0,Lz,10); % 10 z co-ordinate points on surface
wnm=zeros(nmax,length(m));% initial values as place holders
for n=1:nmax
wnm(n,:)=sqrt(D/rowS)*((n*pi./Lx).^2 +(m*pi/Lz).^2); % eq 91 modes for m=1:1000 & n=1:10
end
wp=2*pi*500; % pressure plot @ 500 Hz
[X,Z]=meshgrid(xr,zr);% plane to be plotted on
y = zeros(10,10,1000,10) ;
for xpos= 1:length(X)
for zpos=1:length(Z)
for m=1:1000
for n = 1:nmax
y(:,:,:,n) = ((4/(Lx*Lz))*(F/rowS).*(sin(n.*pi*x0/Lx).*sin(m.*pi.*z0/Lz).*sin(n.*pi.*X(xpos)/Lx).*sin(m.*pi.*Z(zpos)/Lz)).*exp(1j*wp*t))./(-wp^2+wnm(n,:).^2.*(1+1j*eta));% eq 98 notes
end
end
end
end (Source of the subscription error! How do I correct it? Please help)
sumy = sum(y,3) ; % sum of all modes
ydt=real(sumy);%real part displacement due to all modes
figure('NumberTitle','off','Name','Displacment @ 500 Hz')
surf(X,Z,ydt,'EdgeColor','interp');% surface plot
view(-90,90)
xlabel('Length')
zlabel('Displacement')
ylabel('Width')

  2 Comments

We can't see that error until you first let us avoid the first one we get because you have not defined "d".
I hope you are not confused with element wise multiplication(.*) and multiplication(*) while assigning the value to y(:,:,:,n).

Sign in to comment.

2 Answers

Answer by Neuropragmatist on 5 Aug 2019

Type this code in the matlab command line:
dbstop if error
Then run your code and it will stop on a specific line. That line will have some sort of assignment on it that is not possible like:
x(2) = [1 2 3 4 5]
You can look for this by testing the size of the array on the left of the sign and the size of the array on the right of the equals sign. Either the variable on the left is not large enough for what comes after the equals sign or the variable created on the right of the equals sign is too large for some reason (more likely).

  0 Comments

Sign in to comment.


Answer by Navya Seelam on 6 Aug 2019

Hi,
In the line below, RHS has dimensions of 1*1000 and LHS has dimensions 10*10*1000. Make sure the dimensions match to avoid error.
y(:,:,:,n) = ((4/(Lx*Lz))*(F/rowS).*(sin(n.*pi*x0/Lx).*sin(m.*pi.*z0/Lz).*sin(n.*pi.*X(xpos)/Lx).*sin(m.*pi.*Z(zpos)/Lz)).*exp(1j*wp*t))./(-wp^2+wnm(n,:).^2.*(1+1j*eta));

  0 Comments

Sign in to comment.