Using blkbuild with symbolic functions to find the transfer function of a block diagram
21 views (last 30 days)
Show older comments
In the block diagram represented by the following code blocks 1 to 7 are defined as x, where x is a symbolic variable. When the code is executed I get a number of error messages although if n1 through n7 were numeric and not symbolic variables there would be no error. Can someone please explain how the blocks can be expressed as symbolic functions?
syms x
n1 = x; d1 = 1;
n2 = x; d2 = 1;
n3 = x; d3 = 1;
n4 = x; d4 = 1;
n5 = x; d5 = 1;
n6 = x; d6 = 1;
n7 = x; d7 = 1;
nblocks = 7;
blkbuild
q = [1 0 0 0 0; 2 1 -5 0 0; 3 2 -6 0 0; 4 2 -6 3 -7; ...
5 3 0 0 0; 6 3 0 0 0; 7 4 0 0 0]
input = 1; output = 4;
[aa,bb,cc,dd] = connect(a,b,c,d,q,input,output)
[num,den] = ss2tf(aa,bb,cc,dd)
printsys(num,den)
0 Comments
Answers (1)
Suraj Kumar
on 12 Feb 2025 at 4:37
I understand that you're trying to use the blkbuild function in MATLAB to find the transfer function of a block diagram. The issue arises because the blkbuild, connect, and ss2tf functions in MATLAB are designed to work with numeric matrices rather than symbolic expressions. When you try to use symbolic variables, these functions generate errors as they expect numerical data types.
To resolve this, you can use the Symbolic Math Toolbox to define and manipulate symbolic transfer functions directly.You can define each block of your diagram as a symbolic transfer function using MATLAB's symbolic capabilities and can manually combine these transfer functions according to the connections specified in your block diagram.
You can refer to the attched code snippet for better understanding:
syms x s
% Define symbolic transfer functions for each block
H1 = x / 1; % Block 1
H2 = x / 1; % Block 2
H3 = x / 1; % Block 3
H4 = x / 1; % Block 4
H5 = x / 1; % Block 5
H6 = x / 1; % Block 6
H7 = x / 1; % Block 7
% Overall transfer function from input to output
H_total = H1 * H2 * H3 * H4 * H5 * H6 * H7;
% Simplify the expression
H_total = simplify(H_total);
% Display the transfer function
disp('Overall Transfer Function:');
pretty(H_total)
For more information regarding the simplify function in MATLAB, you can refer to the following documentation:
0 Comments
See Also
Categories
Find more on Special Values in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!