How to automatically pull values from matrix and set as variables

I have a matrix ex.
A=[11,7,3;9,13,5],
and I want to have a series of variables where
c1=1
c2=7
c3=3
c4=9
c5=13
c6=5.
How can I do an operation like this for any size matrix and note it is important that they are numbered in a certain direction. This is so in a later operation I can input c5 in an equation and it be the value located in A(2,2).

5 件のコメント

dpb
dpb 2017 年 8 月 2 日
While it is doable; this is almost certainly NOT the way to code whatever it is you have in mind.
Show us the next step of how you intend to use these variables and better solutions will undoubtedly come forth.
Garrett
Garrett 2017 年 8 月 2 日
編集済み: Garrett 2017 年 8 月 2 日
it is supposed to be a fast way of having a user input a string of cells in an equation i.e. instead of typing A(1,1)-A(1,2)+A(2,2) etc. it is so it can be quickly inputted by the user once a path is made in the matrix by instead typing c1-c5+c2 etc
Walter Roberson
Walter Roberson 2017 年 8 月 2 日
You do not need to assign them to variables for this. You can input as a string and analyze the string, pick out the index numbers the user entered and transform them into indices in the original matrix.
Garrett
Garrett 2017 年 8 月 2 日
I am sorry but I do not know who to do that. That sounds right but I have no idea where to start that
Garrett
Garrett 2017 年 8 月 2 日
Never mind, I got it working

サインインしてコメントする。

 採用された回答

Akhilesh Thakur
Akhilesh Thakur 2017 年 8 月 2 日

1 投票

https://stackoverflow.com/questions/14360501/extract-parts-of-a-big-matrix-and-allocate-them-in-new-variables-with-loop-funct
I guess this is what you are looking for Hope this helps.

4 件のコメント

Garrett
Garrett 2017 年 8 月 2 日
that worked thank you
Stephen23
Stephen23 2017 年 8 月 3 日
編集済み: Stephen23 2019 年 6 月 19 日
Akhilesh Thakur
Akhilesh Thakur 2017 年 8 月 3 日
I guess still eval is used everywhere. Thanks for your comments on eval
Akhilesh Thakur
Akhilesh Thakur 2017 年 8 月 3 日
Will try indexing too.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

タグ

質問済み:

2017 年 8 月 2 日

編集済み:

2019 年 6 月 19 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by