# how to create a variable without assigning a value to it and also the variables shouldnt be symbolic variables

25 views (last 30 days)
bhanu kiran vandrangi on 25 Jul 2021
syms e d
m= [27.5084 -10.7668 -9.7727;-20.6533 15.8060 14.8502];
k1=[27.5084*e -10.7668*e -9.7727*e;-20.6533*e 15.8060*e 14.8502*e];
g11=tf([27.5084],[1 0])
g12=tf([ -10.7668],[1 0])
g13=tf([-9.7727],[1 0])
g21=tf([ -20.6533],[1 0])
g22=tf([15.8060],[1 0])
g23=tf([14.8502],[1 0])
k2=[g11 g12 g13;g21 g22 g23]
k3=k2*d
i want the matrix k3 in terms of variable 'd' so i can optimize the matrix with respect to the variable 'd' but that is not happening as d is a sym variable
and also unable to perform any kind of command on k1 as it has sym variable , is there any way to rectify this

Walter Roberson on 25 Jul 2021
syms e d
m = [27.5084 -10.7668 -9.7727;-20.6533 15.8060 14.8502];
k1 = m * e; %not used
k2c = arrayfun(@(V) tf(V,[1 0]), m, 'uniform', false);
k2 = [k2c{1,:}; k2c{2,:}]
k2 = From input 1 to output... 27.51 1: ----- s -20.65 2: ------ s From input 2 to output... -10.77 1: ------ s 15.81 2: ----- s From input 3 to output... -9.773 1: ------ s 14.85 2: ----- s Continuous-time transfer function.
syms S
K2N = cellfun(@(V) poly2sym(V,S), k2.Num)
K2N =
K2D = cellfun(@(V) poly2sym(V,S), k2.Den)
K2D =
k3 = K2N./K2D * d
k3 =
This is symbolic, so you can start manipulating it, and can start optimizing.
bhanu kiran vandrangi on 25 Jul 2021
clc
syms e d
m = [27.5084 -10.7668 -9.7727;-20.6533 15.8060 14.8502];
k1 = m * e;
k2c = arrayfun(@(V) tf(V,[1 0]), m, 'uniform', false);
k2 = [k2c{1,:}; k2c{2,:}]
syms S t
K2N = cellfun(@(V) poly2sym(V,S), k2.Num)
K2D = cellfun(@(V) poly2sym(V,S), k2.Den)
k3 = K2N./K2D * d
K=k1+k3
GP=tfmatrix
CON=K*GP
% where GP is =
GP =
From input 1 to output...
0.005659 s^2 + 0.05206 s + 0.004496
1: -----------------------------------
s^3 + 9.357 s^2 + 2.228 s + 0.06147
0.003013
2: -----------------------------------
s^3 + 9.357 s^2 + 2.228 s + 0.06147
0.0006678 s + 0.003046
3: -----------------------------------
s^3 + 9.357 s^2 + 2.228 s + 0.06147
From input 2 to output...
0.003013
1: -----------------------------------
s^3 + 9.357 s^2 + 2.228 s + 0.06147
0.005659 s^2 + 0.02714 s + 0.004051
2: -----------------------------------
s^3 + 9.357 s^2 + 2.228 s + 0.06147
0.02554 s + 0.004018
3: -----------------------------------
s^3 + 9.357 s^2 + 2.228 s + 0.06147
i am getting a error while executing 'CON' in matlab as mentined above CON=K*GP
how to get past this error

### Categories

Find more on Conversion Between Symbolic and Numeric in Help Center and File Exchange

R2020b

### Community Treasure Hunt

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

Start Hunting!