Multiplication matrix with strings
9 ビュー (過去 30 日間)
古いコメントを表示
how can i multiply matrices with strings, for example [k1-2*m,-k2;-k2,k2]*[1,2;4,6]
1 件のコメント
Luca Ferro
2023 年 2 月 21 日
編集済み: Luca Ferro
2023 年 2 月 21 日
syms k1 k2 m
mult=[k1-2*m,-k2;-k2,k2].*[1,2;4,6]
You need to create symbolic variables before using them.
I'm not sure if you just want to multiply them or element wise multiply them. I decided in my code to element wise multiply them
回答 (1 件)
Star Strider
2023 年 2 月 21 日
編集済み: Star Strider
2023 年 2 月 21 日
Perhaps this —
syms k1 k2 m
M = [k1-2*m,-k2;-k2,k2]*[1,2;4,6] % Symbolic Expression
Mfcn = matlabFunction(M) % Create Numeric Function From It
Result = Mfcn(10,20,30)
The ‘M’ expression will work in a symbolic context, and ‘Mfcn’ can be used in non-symbolic (numeric) MATLAB code.
EDIT — Added ‘Result’ as a demonstration.
.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
