MATLAB Answers

# Why subs symbolic fails here

2 views (last 30 days)
Ole on 1 Sep 2019
Answered: Walter Roberson on 1 Sep 2019
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 CommentsShowHide 1 older comment
Ole on 1 Sep 2019
Because I would like to have simpler expresions.
Then perhaps the question is how to substitute such expressions.

Sign in to comment.

### Accepted Answer

Walter Roberson on 1 Sep 2019
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 CommentsShowHide -1 older comments

Sign in to comment.

R2018a

### Community Treasure Hunt

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

Start Hunting!