Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- close all;
- clear all;
- a=1;
- U=-pi:0.01:pi;
- N=length(U);
- %-------------------1------------------
- m=@(x) (a*x.^2).*(x>-1).*(x<1) + 1.*(x>=1).*(x<2).*(x<=-1).*(x>2) + 0.*(x>=2).*(x<=-2);
- figure(1);
- subplot(3,1,1);
- plot(U, m(U));
- title('1. Wykres uzyskany z charakterystyki nieliniowej.');
- %-------------------2------------------
- sigma=0.035;
- z=sigma*randn(1, N);
- y=m(U)+z;
- subplot(3,1,2);
- hold on;
- plot(U, m(U));
- plot(U, y, 'ro');
- hold off;
- title('2. Wykres z dodana chmura bledu.');
- %-------------------3------------------
- L=50;
- k=10;
- fi0=1/(2*pi);
- for i=1:k
- fi{i}=@(x) (1/pi)*cos(i*x);
- end
- for i=1:k
- alfa{i}=@(x) (1/N)*symsum(y(n)*fi{i}(m(n)),n,1,N);
- end
- for i=1:k
- beta{i}=@(x) (1/N)*symsum(fi{i}(m(n)),n,1,N);
- end
- f_n=@(x) symsum(beta.*fi(x),k,0,L);
- g_n=@(x) symsum(alfa.*fi(x),k,0,L);
- %if f_n == 0
- % m_n = 0;
- %else
- % m_n=@(x) g_n(x)/f_n(x);
- %end
- m_n=@(x) g_n(x)/f_n(x);
- subplot(3,1,3)
- plot(U, m_n(U));
- title('3. Wykres uzyskany z bazy kosinusowej.');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement