Error while multiplying 2 SISO transfer functions.
이전 댓글 표시
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
No issue if run manually here. Maybe something wrong when passing the data type in your transfer functions.
G1 = tf([-0.5 0],[0 1])
G2 = tf([0 1], [0.5 1])
% method 1
G1*G2
% method 2
series(G1, G2)
Bogdan -Ervin
2024년 4월 24일
편집: Bogdan -Ervin
2024년 4월 24일
Sam Chak
2024년 4월 24일
Does the script have symbolic variables and values? Can you check the class and data type?
Bogdan -Ervin
2024년 4월 24일
Bogdan -Ervin
2024년 4월 25일
편집: Bogdan -Ervin
2024년 4월 25일
Bogdan -Ervin
2024년 4월 25일
Sam Chak
2024년 4월 25일
The error message indicates that the first input argument to the multiplication operator (*) should be of class single or double. However, it is important to note that the 'tf' class object represents a dynamic model, which logically should accept any type of linear time-invariant model (such as ss, tf, zpk) in this context.
I would suggest checking if the 'C1' variable, which represents the transfer function in the script, has been inadvertently overwritten by another object of different class.
Bogdan -Ervin
2024년 4월 25일
편집: Bogdan -Ervin
2024년 4월 25일
Sam Chak
2024년 4월 25일
Try saving the C1 and C2 variables (produced by the script) from Workspace to a mat-file.
save dataC1C2.mat
Then upload/attach the mat-file here by clicking the paperclip icon
.
Bogdan -Ervin
2024년 4월 25일
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)
disp(C2)
bode(C1), grid on
bode(C2), grid on
C1*C2
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Dynamic System Models에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

