Error while multiplying 2 SISO transfer functions.
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Bogdan -Ervin
le 24 Avr 2024
Réponse apportée : Sam Chak
le 25 Avr 2024
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 commentaires
Sam Chak
le 25 Avr 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)
disp(C2)
bode(C1), grid on
bode(C2), grid on
C1*C2
Réponse acceptée
Sam Chak
le 25 Avr 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*C2
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Functions dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!