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;
Best Answer