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

조회 수: 2 (최근 30일)
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
Walter Roberson
Walter Roberson 2020년 4월 19일
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 2020년 4월 19일
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)

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2020년 4월 19일
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
Walter Roberson
Walter Roberson 2020년 4월 19일
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 2020년 4월 21일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

제품


릴리스

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by