solve a function without solving for the variable within the function

조회 수: 1 (최근 30일)
Christopher Piland
Christopher Piland 2020년 5월 18일
I am trying to make a Routh Array solver. It works very well when you put integers into it but if I have a variable (like "K" for gain) I can't seem to get it to not solve for K but rather present "K" as part of its answer. I have the code I am working on below. I would like the answers with "K" int them to come out with K in them.
%% 4 element Routh Array
clc
clear all
%S^4 solver
syms k; %Holde K in the array as itself
var=((0.07*k)+0.015)
K=solve(var)
% load the Routh array
%a0s + a1sn + a2sn + a3sn + a4sn
%Example s^4 + 3s^3 + 3s^2 + 2S + 1
a0=1; a1=2.3; a2=1.37; a3=2.65; a4=K; aout=0;
%S4
a0=1 ; a2=3 ; a4=1 ;
S4=[a0 a2 a4];
%S3
a1=3 ; a3=2 ; aout=0;
S3 = [a1 a3 aout];
%S2
b1=((a1*a2)-(a0*a3))/a1; b2=((a1*a4)-(a0*aout))/a1;
S2 = [b1 b2];
%S1
c1=((b1*a3)-(a1*b2))/b1;
S1 = [c1];
%S0
d1=((c1*b2)-(b1*0))/c1;
S0=[d1];
disp('4 Pole S4 Routh Array output NORMAL')
disp(S4)
disp(S3)
disp(S2)
disp(S1)
disp(S0)
ia0=a4; ia1=a3; ia2=a2; ia3=a1; ia4=a0;
%S4
ia0=1 ; ia2=3 ; ia4=1 ;
iS4=[ia0 ia2 ia4];
%S3
ia1=3 ; ia3=2 ; aout=0;
iS3 = [ia1 ia3 aout];
%S2
b1=((ia1*ia2)-(ia0*ia3))/ia1; b2=((ia1*ia4)-(ia0*aout))/ia1;
iS2 = [b1 b2];
%S1
c1=((b1*ia3)-(ia1*b2))/b1;
iS1 = [c1];
%S0
d1=((c1*b2)-(b1*0))/c1;
iS0=[d1];
disp('4 Pole S4 Routh Array output INVERTED')
disp(iS4)
disp(iS3)
disp(iS2)
disp(iS1)
disp(iS0)

답변 (0개)

카테고리

Help CenterFile Exchange에서 Stability Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by