Matrix dimensions must agree error
Mostrar comentarios más antiguos
I keep getting a 'Matrix demensions must agree error' but I don't know why
h = 0.01;
start = 0;
stop = 7;
x = start:h:stop;
w = zeros(size(x));
M = eye(numel(x)-2) .* cos(x);
K = eye(numel(x)-2) .* -2;
v = ones(1, numel(x)-3);
K1 = diag(v, -1);
K2 = diag(v, 1);
K = K + K1 + K2;
K = K .* (1./(h.*h));
A = K + M;
f = ones(1, numel(x));
f = f .* sin(x);
w = A \ f;
plot(x, w);
grid on;
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Operating on Diagonal Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!