0

I'm currently working on an assignment where we want to plot an output function.

Since our input signal( v(t) )is in the Time domain and our transfer function ( H(s) ) is in the S domain. we want to bring our input signal to the S domain so we can simply use multiplication and then bring it back to the time domain to plot.

The error I'm getting is: Error using plot Data must be numeric, datetime, duration or an array convertible to double.

syms s C R L T n

C = (36)10^(-6); % Our given values for capacitance, inductance and resistance L = 0.18; R = 100; T = 1/50; % Period H = 1/(CRs + CL*s^2 + 1); %Transfer function y = 3/2; %c_0

for n = -5:1:5 c_k = (((-1)^n)/(pi(2n+1)))exp(1i(2n+1)100pit); y = y + c_k; end V = laplace(y); Vc = V * H; vc = ilaplace(Vc);

vpa(vc); plot(t,vc);```

1 Answers1

0

I see different issues in this RLC filter circuit.

Here are the modifications you should operate at the end of your program:

vc = real(ilaplace(Vc));%"real" is compulsory even if... it is already real (very small imaginary parts way cree on) 
vvc = string(vc);
close all;hold on;axis([-1,1,-3,3]);
f=str2func(['@(t)(',vvc,')']);%in order to get a function
for t=-1:0.1:1
    plot(t,f(t),'.')
end; 
  1. You have to change types : "syms" type has to be converted into "string" type

  2. You have to convert to real.

  3. "t" is symbolic: Matlab cannot use it as it is; you know that you must give to $t$ a range of values, for example $t=-1:0.1:1$.

  4. We use here the so-called "immediate definition" of a function (https://uk.mathworks.com/help/matlab/matlab_prog/anonymous-functions.html)

  5. What is this function $y$ ? It looks like a truncated Fourier series expansion of a ramp function ?

  6. vpa(...) isn't useful. Instead of for example $2/3$, it gives you $0.66666666666666666666666666...$ with thirty decimals... It's better to keep the fractional form.

  7. The value of T isn't used.

Jean Marie
  • 81,803