How do i get past the dimension mismatch on line 36?

2 次查看(过去 30 天)
L = 0.64; % length of string (m)
T = 122; % tensile force of the string (N)
S=pi/(4e-6); % section of the string
rho = 7.8e6; % mass per unit length of string (kg/m)
c = sqrt(T/rho*S); % wave velocity (m/s)
%t = 1.3; % current time value (s)
xo = L/2; % initial displacement value (m)
% range variables
x = linspace(0,L,1000); % position points on string (m)
n = 1:numel(x); % integers for Fourier series
% pic=length(n)
% poc=length(x)
t = linspace(0,1.3,1000); %current time value (s)
%n = linspace(1,length(x),length(x)); % integers for Fourier series
v = zeros(length(n),length(x)); %tranverse displacement
pac=length(v)
h=4; % height of the string when plucked
part=((2.*(h.*L.^2))./((pi).^2.*n.^2*xo*(L-xo)));% Furier coefficient split
b= part.*sin((n.*pi*xo)./L); % the other half of Fourier coeeficient
w = n.*(pi./L); %angular velocity
for i = 1:length(x)
for j = 1:length(n)
for k=0:length(t)
% v(i,j) = v(i,j)+ % sin(n(j)*pi.*x(i)./L).*cos(c.*n(j).*pi*t./L).*b(j)
half = b(j).*(sin(w(j).*x(i)).*cos(w(j).*c.*t)) %equation split
v(i,j) = v(i,j)+ half;
end
end
end

采纳的回答

Laurent
Laurent 2013-10-31
The problem is with your calculation of 'half'. It uses the variable 't', which is an array (1x1000) and therefore 'half' will be also (1x1000). I think you want 'half' in the line afterwards to be a scalar, so either change the way you calculate 'half', or pick one value from 'half' in the line where you calculate v(i,j).

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by