Transfer Function Implementation with s and sqrt

I am trying to implement the following transfer function:
H = ((2*(acos(sqrt((Vout*(1+(s*TIA_Cf*TIA_Rf)))/(TIA_Rf*Pin*0.9)))))-(3*pi/2))/((2e-7)*(7.8e-3));
However I am getting the error:
Incorrect number or types of inputs or outputs for function 'sqrt'.
Is it because the sqrt() cannot be always a positive number?
How may I handle a situation like this?
Thank you.

6 Comments

You get the error because transfer function inputs are not accepted by sqrt(). I have recreated the error below.
s = tf('s');
sqrt(s)
Incorrect number or types of inputs or outputs for function sqrt.
Trying power, .^ also fails for the same reason, though the error message is explicit here.
And for mpower, ^, the exponent is expected to be an integer.
As for handling the issue, please provide more information as to what you are trying to do / what is the objective here.
I am trying to plot the transfer function of a system described by the previously mentioned equation.
% Input. Voltage measured at the output of the TIA
Vout = 300e-9;
% Input. TIA feedback network capacitance.
TIA_Cf = 1e-12;
% Input. TIA feedback network resistance.
TIA_Rf = 1e3;
% Input. Light Power in [W] generated by the laser.
Pin = 1e-3;
% Transfer Function definition
s = tf('s');
%H = ((2*(acos(sqrt((Vout*(1+(s*TIA_Cf*TIA_Rf)))/(TIA_Rf*Pin*0.9)))))-(3*pi/2))/((2e-7)*(7.8e-3));
% Frequency range for analysis
omega = logspace(0, 3, 100);
% Compute the frequency response
[Mag, Phase] = bode(H, omega);
% Plot the amplitude response
figure;
subplot(2, 1, 1);
semilogx(omega, squeeze(Mag));
title('Amplitude Response');
xlabel('Frequency (rad/s)');
ylabel('Amplitude');
% Plot the phase response
subplot(2, 1, 2);
semilogx(omega, squeeze(Phase));
title('Phase Response');
xlabel('Frequency (rad/s)');
ylabel('Phase (degrees)');
@Anastasios, Can you show the math equation of this code? I want see how it looks like in the true mathematical "Display" mode.
H = ((2*(acos(sqrt((Vout*(1+(s*TIA_Cf*TIA_Rf)))/(TIA_Rf*Pin*0.9)))))-(3*pi/2))/((2e-7)*(7.8e-3));
s is from the Laplace transform or jω.
What do you mean it does not apply to a non linear system?
s definitely is not a parameter as in your code above.
Hi @Anastasios, I'll explain what happened to your code. If you look into the documentation of sqrt(), you will find that the function only accepts inputs of data types such as single, double, table, and timetable. However, 's' is a tf-class data, and thus it threw the "Incorrect number of types of inputs..." error message.
Vout = 300e-9;
TIA_Cf = 1e-12;
TIA_Rf = 1e3;
Pin = 1e-3;
whos Vout TIA_Cf TIA_Rf Pin
Name Size Bytes Class Attributes Pin 1x1 8 double TIA_Cf 1x1 8 double TIA_Rf 1x1 8 double Vout 1x1 8 double
s = tf('s');
whos s
Name Size Bytes Class Attributes s 1x1 1281 tf
%% OP's "transfer function"
H = ((2*(acos(sqrt((Vout*(1+(s*TIA_Cf*TIA_Rf)))/(TIA_Rf*Pin*0.9)))))-(3*pi/2))/((2e-7)*(7.8e-3));
Incorrect number or types of inputs or outputs for function sqrt.

Sign in to comment.

Answers (1)

The transfer function that describes the mapping from the input (input Current) to the output (output Voltage) appears to be the one shown in the image. However, this may not be truly what you are looking for. What exactly is "a [ng]"?
TIA_Cf = 1e-12;
TIA_Rf = 1e3;
%% Transfer function
Gp = tf(TIA_Rf, [TIA_Cf*TIA_Rf 1])
Gp = 1000 ----------- 1e-09 s + 1 Continuous-time transfer function.
%% Bode plot
bode(Gp), grid on

3 Comments

Hi Sam,
[ng] stands for acceleration. Thanks for the reply.
My intention was to solve the first equation for a [ng] acceleration and plot the result vs frequency and voltage.
Probably I have to follow a different approach in resolving this equation.
If nm can be interpreted as nanometer, then ng could be interpreted as nanogram.
Another interpretation could be n times gravity.
Edit - @Anastasios, aren't the things mentioned inside the square brackets units for physical quantities?
The expression boxed in green should also be represented in transfer function form. For example, the Laplace transform of the time-domain is given by .
Could you briefly explain the reason for wanting to find the acceleration?

Sign in to comment.

Asked:

on 4 Dec 2023

Edited:

on 5 Dec 2023

Community Treasure Hunt

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

Start Hunting!