-3

I have a square matrix of coefficients f, and would like to be able to solve these algebraically as a system of simultaneous equations (all the equations f[i,1] + f[i,2]x + ... + f[i, n]z = T for the same T)- the problem is that I don't know how large the matrix is, or what the value of T is going to be.

Is there a way that I can generate a set of equations from a matrix of coefficients, if I don't know in advance how many variables I will need, so that I can use the solve function?

Uzai
  • 121
  • 2
  • Please read [this](https://stackoverflow.com/help/mcve) before asking an unclear question – NKN Mar 30 '17 at 15:18
  • That link is about asking questions about problems with code, which I'm not trying to do - I agree my question isn't especially clear but I'm not sure how better to phrase it. I'm trying to find a way to generate a system of equations without knowing in advance how many variables are involved. – Uzai Mar 30 '17 at 15:25
  • That is the definitive link for how to ask questions on StackOverflow... it's a **coding questions** website, so all of the questions should be about "problems with code"! The answer is probably yes, but you need to give an example and code which you've tried. For example, if your issue is the "unknown size" part, show us code which works for a *known size* and where you are stuck. – Wolfie Mar 30 '17 at 16:11

1 Answers1

0

this is what you want as I understand it:

% random number of coefficients (="unknown size")
n = randi([2,10],1);
% equation system matrix Ax = T
A = rand(n);
T = rand * ones(size(A,1),1);
% solve equations system
x = A\T;
user2999345
  • 4,195
  • 1
  • 13
  • 20