Adding Noise to a signal in S Domain results in error " Vector Lenght must be same"
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Syed Adeel
le 19 Avr 2020
Commenté : Syed Adeel
le 21 Avr 2020
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 commentaires
Walter Roberson
le 19 Avr 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.
Réponse acceptée
Walter Roberson
le 19 Avr 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 commentaires
Walter Roberson
le 19 Avr 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
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!