# Matrices with different numbers of equations

3 views (last 30 days)
Robert Pratt on 24 Mar 2020
Answered: John D'Errico on 24 Mar 2020
I'm supposed to construct a system of equations (Ax=b) matrix that will change depending on the number of equations given. For the forces on a bridge structure, I have equations for the first 4 and the last 4 rows of 'A'. I know how to make a matrix with these but depending on the number of nodes (N) in the structure, the number of equations will change. I'm told 'A' will be a 2N x 2N matrix and 'x' will be a 2N x 1 vector and 'b' is a 2N x 1 vector of constants. I know the equations that are dependent on the number of nodes have to utilize a loop. How would I initialize the 'A' and 'b' matrix with the zeros function manually?

John D'Errico on 24 Mar 2020
You know the size of the matrix. You already know you need to use zeros to initialize it.
A = zeros(2*N,2*N);
b = zeros(2*N,1);
You might want to read the help, especially when you already know what you want to do.