Why subs symbolic fails here

2 ビュー (過去 30 日間)
Ole
Ole 2019 年 9 月 1 日
回答済み: Walter Roberson 2019 年 9 月 1 日
How to make subs work for expression that are not identically simplified from the 'simlify' function.
The expressions bellow are not fully simplified and subs do not substitute.
clear all; close all; clc;
syms a K L
syms m1 b positive;
c = (cos(b)^2 - 2*m1*cos(b)*a)/m1+(m1 - 2*m1^2*cos(b)*a)/(2*m1^2);
cf = subs((c), {cos(b)^2/m1 - 2*cos(b)*a,1/m1 - 2*cos(b)*a}, {K,L})
  2 件のコメント
John D'Errico
John D'Errico 2019 年 9 月 1 日
編集済み: John D'Errico 2019 年 9 月 1 日
Why would you possibly have expected it to succeed? For example, you have the expression:
cos(b)^2/m1 - 2*cos(b)*a
that you wish to replace with something. Yet, there is not even any term of that form. Yes, with algebraic simplicification, you can find a sub-expression like that. But it is not even an issue of simplification, but of factorization. Subs cannot work like that.
Ole
Ole 2019 年 9 月 1 日
Because I would like to have simpler expresions.
Then perhaps the question is how to substitute such expressions.

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

採用された回答

Walter Roberson
Walter Roberson 2019 年 9 月 1 日
cf = subs(2*expand(c), {cos(b)^2/m1 - 2*cos(b)*a,1/m1 - 2*cos(b)*a}, {K,L})/2
cf =
K + L/2

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by