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

1 visualizzazione (ultimi 30 giorni)
Daisy il 31 Ott 2013
Commentato: Daisy il 4 Nov 2013
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
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Laurent il 31 Ott 2013
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).
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Daisy il 4 Nov 2013
thanks it worked

Accedi per commentare.

### Categorie

Scopri di più su Structures in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by