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

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

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.
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

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 Robinson you are exactly on the point. I checked by NUMEL(y2t) and it gives 2500 and time elements are 500. I reallly hope it works. Can you kindly explains the above syntax of arrayfun, how it works. I am reading its document but couldnt understand it fully.
I just tried it as it is. Though it reduces the number to 500 but gives following error:
Error using plot
Invalid second data argument
Error in forMatlab (line 64)
plot(time*1e9,y2t,'-k','LineWidth',2);
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
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 MATLAB 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!