Symbolically solving vectors simultaneously

Hello, I have been trying to solve a vector using the symbolic toolbox and am running into an error that says "Error using maplemex
Error, (in MTM:-solve) 0 variables do not match undefined outputs.", I am currently trying to solve for a variable in a matrix that is equal to zero, below is an example.
syms q0
moment=[5*q0+25 6*q0+45 5*q0+45]
[q0]=solve(moment==0)
This specific example is solving moment equilibrium for a monocoque structure.
Is there a way to solve the seperate q0 values so its a vector like [q0_1 q0_2 q0_3] using the symbolic toolbox?
Thanks!!!

 採用された回答

Star Strider
Star Strider 2022 年 4 月 30 日

0 投票

One solve statement (such as in the original post) also fails in R2022a. One option to get all of the solutions is arrayfun that should be available (another is an explicit loop) —
syms q0
moment = [5*q0+25 6*q0+45 5*q0+45];
q0 = arrayfun(@(x)solve(x), moment)
q0 = 
.

5 件のコメント

Ramses Young
Ramses Young 2022 年 4 月 30 日
Trying that, copy and pasting your code, I get the error
"Error using arrayfun
Unsupported ARRAYFUN input type: sym"
Star Strider
Star Strider 2022 年 4 月 30 日
Unfortunately, I cannot test my code in R2018a.
Option 2
syms q0
moment = [5*q0+25 6*q0+45 5*q0+45];
for k = 1:numel(moment)
q0(k) = solve(moment(k));
end
q0
q0 = 
.
Walter Roberson
Walter Roberson 2022 年 4 月 30 日
arrayfun() might not be able to work with Maple sym, so using a loop might be the best.
Ramses Young
Ramses Young 2022 年 5 月 1 日
I decided to completely uninstall maple and reinstall all the matlab toolboxes and these to have fixed all the maple stuff that was causing issues. Kinda annoying that Maple makes the matlab stuff not work correctly. But thank you all for the help!
Star Strider
Star Strider 2022 年 5 月 1 日
As always, my pleasure! (And thanks to Walter for his observations.)

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

その他の回答 (1 件)

Paul
Paul 2022 年 4 月 30 日

0 投票

q0 = sym('q0_',[1 3])
q0 = 
moment=[5*q0(1)+25 6*q0(2)+45 5*q0(3)+45]
moment = 
solve(moment==0,q0)
ans = struct with fields:
q0_1: -5 q0_2: -15/2 q0_3: -9

2 件のコメント

Walter Roberson
Walter Roberson 2022 年 4 月 30 日
I do not recall whether the interface to maple supports using sym that way to create a vector. Maybe?
Ramses Young
Ramses Young 2022 年 4 月 30 日
This didnt work for me, It is giving me the same error I put in the post... is there a way to go around this??
Thanks!

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

カテゴリ

製品

リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by