I have the following code to achieve W_n
%%CONSTANTS & VARIABLES
clear all; close all;L_x = 27.4e-3; % membrane width (m)
L_y = 27.4e-3; % membrane height (m)
N_x = 3; % no. of x dim. eigenfreqs
N_y = 3; % no. of y dim. eigenfreqs
N = N_x*N_y; % total no. of eigenfreqs
numX = 101; % no. of x-dir. mapping points
numY = 101; % no. of y-dir. mapping points
xs = linspace(0,L_x,numX); % x-dir. membrane mapping points
ys = linspace(0,L_y,numY); % y-dir. membrane mapping points
%%SET UP MESHES
[X,Y] = meshgrid(ys,xs); % create X and Y array in 2d
XFull = repmat(X, [1 1 N]); % modify X and Y array for 3d
YFull = repmat(Y, [1 1 N]); % modify X and Y array for 3dR = ones(numX, numY, N_x);% create mode array for X
RFull = []; % create an empty array (0 by 0)
for n = 1:N_x RFull = cat(3, RFull, n*R);endS = ones(numX, numY); % create mode array for Y
SFull = []; % create an empty array (0 by 0)for n = 1:N_y SFull = cat(3, SFull, n*S);endSFull = repmat(SFull, [1 1 N_x]);A = ones(numX, numY, N_x);% create mode array for XAFull = []; % create an empty array (0 by 0)for n = 1:N_x AFull = cat(3, AFull, n*A);endB = ones(numX, numY); % create mode array for YBFull = []; % create an empty array (0 by 0)for n = 1:N_y BFull = cat(3, BFull, n*B);endBFull = repmat(BFull, [1 1 N_x]);%%W_n
% 1st method
W_n_i = arrayfun(@(x,r,y,s)sin(x.*r*pi/L_x).*sin(y.*s*pi/L_y)... ,XFull,RFull,YFull,SFull);% 2nd method
% W_n_x = arrayfun(@(x,r)sin(x.*(r*pi/L_x)), XFull, RFull);
% W_n_y = arrayfun(@(y,s)sin(y.*(s*pi/L_y)), YFull, SFull);
% W_n_ii = W_n_x .* W_n_y; % mode superposition
W_n = W_n_i; % choose 'i' or 'ii'
I can't work out why W_n_i is different to W_n_ii.
Could anyone help me to see why this is?
Many thanks in advance.
Best Answer