Команда SIMPLE , по-видимому, не предлагает никакого способа вернуть all различные формы символического выражения в качестве выходного аргумента. Он возвращает только самый простой и отображает остаток в окне команд.
Если вы хотите избежать необходимости вырезать и вставлять из окна команд, вы можете использовать эту функцию, которую я написал, которая использует команду EVALC (как предложено Andrew Janke ) чтобы захватить вывод, отображаемый в окне команд:
function allEquations = simple_forms(S)
output = evalc('simple(S);'); %# Capture the output from the
%# Command Window
newlineIndex = find(output == char(10)); %# Get the indices of newlines
lineSizes = diff([0 newlineIndex]); %# Get the sizes of each line
output = mat2cell(output,1,lineSizes); %# Put the lines in a cell array
output = deblank(output); %# Remove blank spaces
emptyIndex = cellfun(@isempty,output); %# Find the indices of empty lines
output(emptyIndex) = []; %# Remove the empty lines
allEquations = output(2:2:end); %# Get the even lines (where the
%# formulae are)
allEquations = cellfun(@sym,allEquations,... %# Convert the formulae to
'UniformOutput',false); %# symbolic expressions
end
Эта функция вернет массив ячеек, содержащий символические формы всех уравнений, сгенерированных SIMPLE . Вам просто нужно выбрать тот, который вы хотите, например:
>> eq1 = sym('sin(t)*cos(t)^2-sin(t)*cos(t)^4'); %# Create a symbolic equation
>> eqs = simple_forms(eq1); %# Get the different forms
>> eqs{1} %# Pick the first formula
ans =
sin(3*t)/16 - sin(5*t)/16 + sin(t)/8