Try to use solve but getting "Error in MuPAD command: Index exceeds matrix dimensions"

1 回表示 (過去 30 日間)
Hello,
I get the following error message when I try to use solve using a system of equations and specifying the variables to be solved for:
Error in MuPAD command: Index exceeds matrix dimensions.
Essentially, I have 7 equations with 3 variables (a, lambda1 and lambda2) and one parameter (2). Below is my source code. I am using the Student version of MATLAB R2010a.
syms a s lambda1 lambda2;
S = solve('lambda1 - lambda2 + 1=0','a>=0', 's/2 - a >= 0', 'a*lambda1=0','lambda2*(s/2 - a)=0','lambda1>=0','lambda2>=0','a','lambda1','lambda2');
Please note that when I take away either the 'a', 'lambda1', or the 'lambda2' (i.e. so that I am just solving for 2 variables instead of 3), then the error message goes away. But when I try to solve for all 3 variables 'a', 'lambda1' and 'lambda2', then I get the error message.

採用された回答

Walter Roberson
Walter Roberson 2017 年 7 月 9 日
This appears to be the same bug as https://www.mathworks.com/support/bugreports/677110 except no trig is involved.
Workaround:
Call the MuPAD symbolic engine directly. For example,
>> S = evalin(symengine,'solve([p1-y1,p2-y2,p3-sin(y3)],[y1,y2,y3])')
  1 件のコメント
Trevor Gates
Trevor Gates 2017 年 7 月 9 日
Thank-you, that worked beautifully! Below is how I was able to implement it in my code:
text = ['solve([',eq1,', ', eq3, ', ', eq4, ', ', eq3a, ', ', eq4a, ', ', eq6a, ', ', eq6b, '], [a])'];
[a_sol] = evalin(symengine,text);

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MuPAD についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by