MATLAB: Adding Noise to a signal in S Domain results in error ” Vector Lenght must be same”

MATLABsignal processing

I am running the Script which is attached in attachment. It gives perfect output when I add noise to output signal in time domain for Plotting.
However due to design requirement I need to take the Laplace of Noise and add it to Input Signal(in S domain) for futher processing.
NOTE: (CD=60e-12; its missing in script)
y(s)=H(s)*[X(s)+N(s)]
Where Y(s) is output
X(s) is input.
Y(s) is output.
N(S) is Noise.
However when I take Laplace of Noise and add it to input Signal its lenght Mismatches and gives error. Can Anyone Please Help In This Regard.

Best Answer

  • I do not get an error there. However,
    y1s=tfvout2*XS;
    would be a 1 x 500 because XS is 1 x 500, so
    y1tid=ilaplace(y1s);
    would be 1 x 500. Then you go to
    y2t=subs( y1tid,{t},{time}); % Output in Time domain

    which is asking that the 1 x 500 input time be substituted into each of the 1 x 500 y1tid, not substituting corresponding values. For corresponding you need something like
    y2t = arrayfun(@(Y1, T) subs( Y1, t,T), y1tid, time); % Output in Time domain