3D matrix manipulation problems
Show older comments
I struggle with this generally and have come up against a barrier again.
I'm trying to create vibrational mode functions for a rectangular membrane. The equation is simple enough: -
W_n = sin(x*pi*i/L_x)*sin(y*pi*i/L_y)
Here's where I'm up to: -
L_x = 27.4e-3; %membrane width (m)
L_y = 27.4e-3; %membrane height (m)
N_x = 10; %no. of eigenfreqs considered in x dimension
N_y = 10; %no. of eigenfreqs considered in y dimension
N = N_x*N_y; %total no. of eigenfreqs considered
x = (linspace(0.5*L_x/N_x,L_x - 0.5*L_x/N_x,N_x))';
%membrane x-dimension mapping points
%each at the centre of an element
y = (linspace(0.5*L_y/N_y,L_y - 0.5*L_y/N_y,N_y));
%membrane y-dimension mapping points
%each at the centre of an element
x_ref = 1:length(x);
y_ref = 1:length(y);
W_n = zeros(N_x,N_y,N);
W_n(:,:,01) = (sin(x(x_ref,:,:)*1*pi/L_x)...
*sin(y(:,y_ref,:)*1*pi/L_y));
W_n(:,:,02) = (sin(x(x_ref,:,:)*1*pi/L_x)...
*sin(y(:,y_ref,:)*2*pi/L_y));
W_n(:,:,18) = (sin(x(x_ref,:,:)*2*pi/L_x)...
*sin(y(:,y_ref,:)*8*pi/L_y));
W_n(:,:,46) = (sin(x(x_ref,:,:)*5*pi/L_x)...
*sin(y(:,y_ref,:)*6*pi/L_y));
W_n(:,:,89) = (sin(x(x_ref,:,:)*9*pi/L_x)...
*sin(y(:,y_ref,:)*9*pi/L_y));
W_n(:,:,100) = (sin(x(x_ref,:,:)*10*pi/L_x)...
*sin(y(:,y_ref,:)*10*pi/L_y));
The numbers on the left hand side - 01, 02, 18, 46, 89, 100 - actually need to be 1,2,3,...,100, i.e.
n = 1:100; %mode number counting from 1 to 100
These refer to the mode numbers - although this is a bit odd - but still not too complicated. Basically if n = 01, then the mode is (1,1). If n = 59 the mode is (6,9), i.e. i = 6 & j = 9. I have solved this using the following: -
i = floor((n/10 - n/1000)) + 1;
%mode number from 1 to 10 in x dimension
j = n - 10*(floor((n/10 - n/1000)));
%mode number from 1 to 10 in y dimension
Now I just need to put n, i and j into my W_n equation, but I can't figure out how!
Any help would be greatly appreciated :)
Accepted Answer
More Answers (0)
Categories
Find more on Mathematics in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!