Matrix dimensions must agree error
Show older comments
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;
Accepted Answer
More Answers (0)
Categories
Find more on Operating on Diagonal Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!