Question

Hi I need help understanding this matlab code. Can you add comments or at least state what the lines in this code are doing. Thanks! close all; clear all;clc; t=1:0.025:5; desired=5*sin(2*3.*t); noi...

Hi I need help understanding this matlab code. Can you add comments or at least state what the lines in this code are doing. Thanks!

close all;
clear all;clc;

t=1:0.025:5;
desired=5*sin(2*3.*t);

noise=5*sin(2*50*3.*t);

refer=5*sin(2*50*3.*t+ 3/20);

primary=desired+noise;

subplot(4,1,1);
plot(t,desired);
ylabel('desired');


subplot(4,1,2);
plot(t,refer);
ylabel('refer');



subplot(4,1,3);
plot(t,primary);
ylabel('primary');



order=2;
mu=0.005;
n=length(primary)
delayed=zeros(1,order);
adap=zeros(1,order);
cancelled=zeros(1,n);

for k=1:n,
delayed(1)=refer(k);
y=delayed*adap';
cancelled(k)=primary(k)-y;
adap = adap + 2*mu*cancelled(k) .* delayed;
delayed(2:order)=delayed(1:order-1);
end

subplot(4,1,4);
plot(t,cancelled);
ylabel('cancelled');

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Po al Signd platブoph七ㄜ邯 Plot-e, eben) fr al ず Im Varu equaivI au

Add a comment
Know the answer?
Add Answer to:
Hi I need help understanding this matlab code. Can you add comments or at least state what the lines in this code are doing. Thanks! close all; clear all;clc; t=1:0.025:5; desired=5*sin(2*3.*t); noi...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • can anyone help me for describing how this cods work?? pleasssse help me

    1.  close all;2.  clear all;clc;3.   4.   t=1:0.025:5;5.   desired=5*sin(2*3.*t);6.   7.   noise=5*sin(2*50*3.*t);8.   9.   refer=5*sin(2*50*3.*t+ 3/20);10.  11.  primary=desired+noise;12.  13.  subplot(4,1,1);14.  plot(t,desired);15.  ylabel('desired');16.  17.  18. subplot(4,1,2);19.  plot(t,refer);20.  ylabel('refer'); 21.  22.  23.  24.  subplot(4,1,3);25.  plot(t,primary);26.  ylabel('primary');27.  28.   29.  30.  order= 2;31.  mu=0.005;32.  n=length(primary)33.  delayed=zeros(1,order);34.  adap=zeros(1,order);35.  cancelled=zeros(1,n);36.  37.  for k=1:n,38.      delayed(1)=refer(k);39.      y=delayed*adap';40.      cancelled(k)=primary(k)-y;41.      adap = adap + 2*mu*cancelled(k) .* delayed;42.      delayed(2:order)=delayed(1:order-1);43.  end44.  45.  subplot(4,1,4);46.  plot(t,cancelled);47.  ylabel('cancelled');

  • I have all of the answers to this can someone just actually explain this matlab code and the results to me so i can get a better understanding? b) (c) and (d) %% Matlab code %% clc; close all; clear...

    I have all of the answers to this can someone just actually explain this matlab code and the results to me so i can get a better understanding? b) (c) and (d) %% Matlab code %% clc; close all; clear all; format long; f=@(t,y)y*(1-y); y(1)=0.01; %%%% Exact solution [t1 y1]=ode45(f,[0 9],y(1)); figure; plot(t1,y1,'*'); hold on % Eular therom M=[32 64 128]; T=9; fprintf(' M Max error \n' ); for n=1:length(M) k=T/M(n); t=0:k:T; for h=1:length(t)-1 y(h+1)=y(h)+k*f(t(h),y(h)); end plot(t,y); hold on %%%...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT