4.0

4.0 | 1 rating Rate this file 0 Downloads (last 30 days) File Size: 6.67 KB File ID: #25070

Substitute Expressions in Matlab

by Shaminda Subasingha

 

18 Aug 2009 (Updated 20 Aug 2009)

Substitute parts of a equation (mathematical expression). Helpful in simplifying long expressions.

| Watch this File

File Information
Description

This function provides a supplement to the Matlab Symbolic toolbox to substitute and simplify long expressions. Maple does not provide this functionality.
input-- Input expression that has some terms to be substituted.
                 >> input='a^2-2b+c-3';
                  >> inputmode=1;
              Note that 'inputmode=1' indicates that the input is a
             string expression;
               
 subexp-- If ‘subexp’ can be found inside 'input' expression, then all the instances of ‘subexp’ are substituted with the expression 'var'
outputmode-- output is a character string if ‘outputmode=1’;

Note: Read help for the other options.

EXAMPLE:

input='a^2-2*b+c-3';
subexp='c+a^2';
var='Z'
inputmode=1;
outputmode=1;
out=SubsExp(input,subexp,var,inputmode,outputmode);
 

ANSWER
>>out =Z - 2*b - 3

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
24 Aug 2009 Erdal Bizkevelci  
Please login to add a comment or rating.
Updates
18 Aug 2009

Corrected some typos in the introduction

20 Aug 2009

Made the introduction simpler. Changed the summary.

Tag Activity for this File
Tag Applied By Date/Time
statistics Shaminda Subasingha 18 Aug 2009 17:08:24
optimization Shaminda Subasingha 18 Aug 2009 17:08:24
symbolic Shaminda Subasingha 18 Aug 2009 17:08:24
simplyfy Shaminda Subasingha 18 Aug 2009 17:08:24
substitute Shaminda Subasingha 18 Aug 2009 17:08:24
expression Shaminda Subasingha 18 Aug 2009 17:08:24
simplify Shaminda Subasingha 21 Aug 2009 11:53:27
equation Shaminda Subasingha 21 Aug 2009 11:53:27

Contact us at files@mathworks.com