Converting inputdlg entries to symbols in a matrix
1 回表示 (過去 30 日間)
古いコメントを表示
Code for non-symbol case:
Matrices = inputdlg({'Matrix 1', 'Matrix 2'})
Matrix1 = str2num(Matrices{1})
Matrix2 = str2num(Matrices{2})
Product = Matrix1*Matrix2
I have tried the following but it does not work.
str2sym(Matrices{1})
I want the user to be able to enter somethig like a 40; c 20 and have this converted to a matrix whilst recognising the letters as symbolic values.
0 件のコメント
回答 (1 件)
Walter Roberson
2021 年 7 月 8 日
You need to have [] around the entries. str2sym() will not assume that a space is to indicate a list.
Matrices = {'40', 'c 20'}
str2sym(Matrices{1})
str2sym("["+ Matrices{2}+"]")
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Operators and Elementary Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!