I am quite new to coding and trying to create a row where each term in the row is x followed by the column number in brackets. So [x(1) x(2) x(3) … x(n)]
Many thanks
Best Answer
I suggest going through MATLAB Onramp. Chps 4 and 5 seems to be relevant to what you are asking.
You might also just be needing to transpose you column vector to turn it into a row vector. Use ' for that. This is covered in 4.2.6.
Believe it or not, you didn't put a space before the constant in the 3rd and 4th elements ofF. Notice that they both end inblahblah -3.1415926
MATLAB is interpreting that space before the minus sign (and lack of space after it) as two elements on that row -- ie equivalent toblahblah,-3.1415926. Take out the space before the minus sign or add one after it (before the constant).
BTW, rather than lettingfsolve find the error, do a quick check by callingmoments directly from the Command Window:moments([1;2;3;4;5])
Best Answer