Adding Noise to a signal in S Domain results in error " Vector Lenght must be same"

1 view (last 30 days)
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.
  2 Comments
Walter Roberson
Walter Roberson on 19 Apr 2020
tfvout2=subs(tf.vout,{Gm1,rf,r1,r2,r34,rl,cf,capd,iin},{gm1,Rf,R1,R2,R34,RL,Cf,CD,1});
CD does not exist.
Syed Adeel
Syed Adeel on 19 Apr 2020
sorry if that is missing
CD=60e-12;
And in the attached code, noise vector is attached to output and yea thats work. I want to change it so I can add the laplace of Noise vector to input x1s (which is commented in code)

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 19 Apr 2020
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
  3 Comments
Walter Roberson
Walter Roberson on 19 Apr 2020
The general syntax for arrayfun() as used here is:
y2t = arrayfun(FUNCTION_HANDLE, ARRAY1, ARRAY2, ARRAY3, ...)
and it is pretty much equivalent to
y2t = zeros(size(ARRAY1), 'sym');
for idx = 1 : numel(ARRAY1)
y2t(idx) = FUNCTION_HANDLE(ARRAY1(idx), ARRAY2(idx), ARRAY3(idx), ...);
end
which is to say it takes corresponding elements of the input arrays and passes them to the function handle and saves the result.
In this case, the corresponding inputs would be one formula from y1tid, and one time from the time vector.
Another way to write it would be
y2t = zeros(size(ARRAY1), 'sym');
for idx = 1 : numel(ARRAY1);
y2t(idx) = subs(t1tid(idx), t, time(idx));
end
Syed Adeel
Syed Adeel on 21 Apr 2020
Hey @walter Thqnk you so much. I just logged in to say thankyou for your help. I forogt to accept your answer, it worked. I love you man

Sign in to comment.

More Answers (0)

Categories

Find more on Simulink in Help Center and File Exchange

Products


Release

R2016a

Community Treasure Hunt

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

Start Hunting!