Clear Filters
Clear Filters

Error while multiplying 2 SISO transfer functions.

9 views (last 30 days)
I have a script that reads transfer functions from .mat files, and I have what it looks like to be tf([-0.5 0],[0 1]) (I will note this with C1) and tf([0 1],[0.5 1]) (I will note this with C2). When I do the operation C1 * C2, I get the error:
"Error using *
First argument must be single or double."
I have also tried series(C1,C2), but I get the same error. (Both of them are tf type variables.)
Why I can not multiply those 2 transfer functions? Since I can not include my code (because I use multiple classes and the reader would need a repository to understand what those classes do) I am satisfied with theoretical scenarios regarding the nature of the error like "the number of inputs of C1 is not the same as the number of outputs of C2" (but this is not the case, since both are SISO tf).
Edit: tf is not overriden and it is the same tf as Transfer function model - MATLAB (mathworks.com).
Edit 2: I have tried with some other tf for C2, and I have found that if C2 is a static gain, the multiplication is done without any issue. But if C2 has numerator or/ and denominator a polynom with 2 or more coefficients (dominant coefficient non zero), the "First argument must be single or double" error is displayed.
  11 Comments
Sam Chak
Sam Chak on 25 Apr 2024
This is for recreating the error message "First argument must be single or double." Although C1 is an improper transfer function, it cannot even produce the Bode diagram.
load('dataC1C2.mat')
disp(C1)
tf with properties: Numerator: {[-0.5000 0]} Denominator: {[0 1]} Variable: 's' IODelay: [0] InputDelay: [0] OutputDelay: [0] InputName: {''} InputUnit: {''} InputGroup: [1x1 struct] OutputName: {''} OutputUnit: {''} OutputGroup: [1x1 struct] Notes: [0x1 string] UserData: [] Name: '' Ts: [0] TimeUnit: 'seconds' SamplingGrid: [1x1 struct]
disp(C2)
tf with properties: Numerator: {[0 1]} Denominator: {[0.5000 1]} Variable: 's' IODelay: [0] InputDelay: [0] OutputDelay: [0] InputName: {''} InputUnit: {''} InputGroup: [1x1 struct] OutputName: {''} OutputUnit: {''} OutputGroup: [1x1 struct] Notes: [0x1 string] UserData: [] Name: '' Ts: [0] TimeUnit: 'seconds' SamplingGrid: [1x1 struct]
bode(C1), grid on
Warning: Error occurred while evaluating listener callback.
bode(C2), grid on
C1*C2
Error using * (line 77)
First argument must be single or double.

Sign in to comment.

Accepted Answer

Sam Chak
Sam Chak on 25 Apr 2024
load('dataC1C2.mat')
While I haven't been able to pinpoint the exact root cause of the issue, I can suggest a workaround below that you can try.
Simply add the following line of code to your script, right after the generation of the old C1 transfer function. This addition should help create a new C1 transfer function and hopefully eliminate the error you encountered.
Please give it a try and let me know if it resolves the problem.
%% Add this line:
C1 = tf(C1.Numerator{:}, C1.Denominator{:})
C1 = -0.5 s Continuous-time transfer function.
C1*C2
ans = -0.5 s --------- 0.5 s + 1 Continuous-time transfer function.

More Answers (0)

Categories

Find more on Functions in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!