# How to solve for discrete state space matrices given input and output

I have a set of time-series data that consists of inputs $$u_k$$ where $$u \in R$$ and $$k = 1 ... T$$, and outputs $$y_k$$ where $$y \in R^2$$ and also $$k = 1 ... T$$, from a given system. I believe this system can be modeled in discrete canonical state space form as $$x_{k+1} = Fx_k + Gu_k$$ $$y_{k+1} = Cx_{k+1}$$ In this case, $$y_{k} = x_{k}$$ so the form becomes $$y_{k+1} = Fy_k + Gu_k$$ Given all of the $$y_k$$ and $$u_k$$ I am fairly sure that I should be able to solve for $$F$$ and $$G$$, but how do I actually do this? Some work on paper got me nowhere and I can't seem to find anything on the internet.

• The general topic is "System Identification", but I think for success you probably need some idea of what your system is. Me being me I'd switch to the frequency domain and get a transfer function. au.mathworks.com/help/ident/gs/about-system-identification.html Jan 4 at 0:33
• 1 Is $F$ a $2\times 2$ matrix ? 2 are the measurements $y_k$ noisy ? i.e. $y_{k+1} = Cx_{k+1} + \mathbf{w_{k+1}}$ where $w$ is unknown noise.
– AJN
Jan 4 at 12:09
• @AJN 1) Yes 2) yes but negligibly so, which is why I excluded it. Jan 4 at 15:26
• OK, so what are the dimensions of y and u? Jan 4 at 17:25
• Have you seen papers using Hankel matrices and Singular value decomposition methods like these ? 1, 2, 3
– AJN
Jan 5 at 15:47

The answer to this turned out to be to frame the problem as a least-squares problem. Specifically I found & used State Space Model Identification by Least Squares. This allowed me to solve for the rows of $$F$$ and $$G$$ one-by-one.
{"ft_lang_label":"__label__en","ft_lang_prob":0.8896096,"math_prob":0.9995572,"size":1731,"snap":"2023-40-2023-50","text_gpt3_token_len":545,"char_repetition_ratio":0.1134916,"word_repetition_ratio":0.012307692,"special_character_ratio":0.33448875,"punctuation_ratio":0.10928962,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9999442,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-10-02T14:02:24Z\",\"WARC-Record-ID\":\"<urn:uuid:cb7b8e76-4a4c-47e5-9723-ddab2c97ef41>\",\"Content-Length\":\"162779\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:44e2795f-aaa8-4bbe-87b5-d0a8745db5ce>\",\"WARC-Concurrent-To\":\"<urn:uuid:29b8414b-267c-467d-b147-39e0d165c0c0>\",\"WARC-IP-Address\":\"104.18.11.86\",\"WARC-Target-URI\":\"https://engineering.stackexchange.com/questions/53766/how-to-solve-for-discrete-state-space-matrices-given-input-and-output\",\"WARC-Payload-Digest\":\"sha1:LO37QEKQWOBFPTNLWWDSWDQQY2FGMS5X\",\"WARC-Block-Digest\":\"sha1:2KDWH4ASY2C4TRIMU5IRYVSHLBYEKXWJ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233511000.99_warc_CC-MAIN-20231002132844-20231002162844-00593.warc.gz\"}"}