필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
Daisy
Daisy 2013년 10월 31일
댓글: Daisy 2013년 11월 4일
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에서 String Parsing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by