MATLAB: Updating element defined as a variable in a matrix for a given range

MATLABmatrix element

Hello,
I created a gauss elimination with partial pivoting and back substitution to solve a system of linear equations. What I am having trouble with is creating a matrix that has an element defined as a variable that is updated for a given range of numbers in order to produce a number of solutions based on the range and increments provided. I recieve the following error message:"Error using vertcat: Dimensions of arrays being concatenated are not consistent."
Thank you for your help.
function [x] = FwdElimPPivBckSub(A,b)
tic
R3 = (30.1:.1:100);
A = [1 -1 -1 0 0;
0 0 1 -1 -1;
30 0 0 -25 -25;
-25 0 R3 0 -6;
0 0 -6 0 21;];
b = [0; 0; 110; 0; -45];
n = length(b);
for k = 1:n-1
p = k;
big = abs(A(k,k));
for ii = k+1:n
dummy = abs(A(ii,k));
if dummy > big
p = ii;
end
end
if p ~= k
for jj = k:n
dummy = A(p,jj);
A(p,jj)= A(k,jj);
A(k,jj)= dummy;
end
dummy = b(p);
b(p) = b(k);
b(k) = dummy;
end
for i = k+1:n
factor = A(i,k)/A(k,k);
for j = k+1:n
A(i,j) = A(i,j)-factor *A(k,j);
end
b(i) = b(i) - factor*b(k);
end
end
for i = 1:n
x(i) = b(i)/A(i,i);
end
for i = n-1:-1:1
sum = b(i);
for j = i+1:n
sum = sum - A(i,j)*x(j);
end
x(i) = sum/A(i,i);
end
toc

Best Answer

R3 = (30.1:.1:100);
R3 is now 1 x 700
A = [1 -1 -1 0 0;
0 0 1 -1 -1;
30 0 0 -25 -25;
first row, second row, third are all 1 x 5
-25 0 R3 0 -6;
There is an R3 in the middle there, and it is 1 x 700, so this line is 1 x (2 + 700 + 2) which is 1 x 704
0 0 -6 0 21;];
and that line is 1 x 5.
What I am having trouble with is creating a matrix that has an element defined as a variable that is updated for a given range of numbers in order to produce a number of solutions based on the range and increments provided.
You pass in A and b. You should not be defining them inside the function. You should be calling the function in a loop, passing in different variations of A, and doing something appropriate with the results returned by the function.