Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 11111111111111111111111111111111111111
- d = sortrows(csvread('LoudnessWarNumbers.csv'));
- tmp=0;
- suma=0;
- k=0;
- %uśrednianie poszczególnych lat
- for i=1:length(d)
- if(d(i)~=tmp)
- tmp=d(i);
- k = k+1;
- D(k,4)=0;
- suma(k)=0;
- end
- D(k,:) = D(k,:) + d(i,:);
- suma(k)=suma(k)+1;
- end
- for i=1:k
- D(i,:) = D(i,:)/suma(i);
- end
- X=[ones(23,1) D(:,1)];
- y_sr=D(:,2);
- y_max=D(:,3);
- y_min=D(:,4);
- %metoda najmniejszych kwadratow
- a1=inv(X'*X)*X'*y_sr
- a2=inv(X'*X)*X'*y_max
- a3=inv(X'*X)*X'*y_min
- t=1981:0.1:2013;
- subplot(2,2,1)
- hold on
- title('Srednia');
- plot(t,t*a1(2)+a1(1),'r')
- plot(D(:,1),y_sr,'.r')
- hold off
- subplot(2,2,2)
- hold on
- title('Maksymalna');
- plot(t,t*a2(2)+a2(1),'b')
- plot(D(:,1),y_max,'.b')
- hold off
- subplot(2,2,3)
- hold on
- title('Mminimalna');
- plot(t,t*a3(2)+a3(1),'g')
- plot(D(:,1),y_min,'.g')
- hold off
- .............................................
- 1111111bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
- dane = sortrows(csvread('LoudnessWarNumbers.csv'));
- n=0;
- suma=0;
- k=0;
- for i=1:length(dane)
- if(dane(i)~=n)
- n=dane(i);
- k = k+1;
- usrednione(k,4)=0;
- suma(k)=0;
- end
- usrednione(k,:) = usrednione(k,:) + dane(i,:);
- suma(k)=suma(k)+1;
- end
- for i=1:k
- usrednione(i,:) = usrednione(i,:)/suma(i);
- end
- X=[ones(23,1) usrednione(:,1)];
- album=usrednione(:,2);
- maxdyn=usrednione(:,3);
- mindyn=usrednione(:,4);
- a1=inv(X'*X)*X'*album;
- a2=inv(X'*X)*X'*maxdyn;
- a3=inv(X'*X)*X'*mindyn;
- t=1981:0.1:2013;
- plot(t,t*a1(2)+a1(1),usrednione(:,1),album,'.')
- ---------------------------------------------------------------------------------
- 222222222222222
- clear all
- close all
- load sndb_prbs;
- M=30; % długość licznika
- L=length(u);
- U=[]; % Metoda parametryczna model FIR o długości M
- for i=1:M
- U=[U, u(M-i+1:L-i+1)];
- end
- Y=y(M:L);
- b=U\Y;
- Hls=freqz(b(1:M),1, round(L/2));
- ids=1:L/2;
- Freqs=(ids-1)*fs/L;
- plot( Freqs', 20*log10(abs(Hls(1:end-1))), 'r-' );
- cor=xcorr(u,y);
- for i=98304:196607
- trans(i)=fft(cor(i));
- end
- plot(trans)
- -------------------------------------------------------------------------------------------------------
- 333333333333333333
- close all
- clear all
- i1=imread('Krata1.jpg');
- i1g=double(rgb2gray(i1));
- [sx, sy]=size(i1g);
- cx=sx/2; cy=sy/2;
- % wyszukanie przecięć linii
- wzorzec=[
- 0 0 0 1 1 1 0 0 0
- 0 0 0 1 1 1 0 0 0
- 0 0 0 1 1 1 0 0 0
- 1 1 1 1 1 1 1 1 1
- 1 1 1 1 1 1 1 1 1
- 1 1 1 1 1 1 1 1 1
- 0 0 0 1 1 1 0 0 0
- 0 0 0 1 1 1 0 0 0
- 0 0 0 1 1 1 0 0 0];
- ic=normxcorr2(wzorzec,i1g);
- ig=ic<-0.7;
- ig=bwmorph(ig,'shrink',Inf);
- [ix,iy]=find(ig>0); % współrzędne przecięć linii
- r=sqrt((ix-cx).^2+(iy-cy).^2); % promień do środka obrazu
- [rs,i]=sort(r);
- % ustalenie punktów odniesienia (siatki regularnej)
- x0=ix(i(1)); y0=iy(i(1));
- dx=abs(ix(i(1))-ix(i(4)))-1;
- dy=abs(iy(i(1))-iy(i(4)))-3;
- jx=x0+dx*[-4:1:5];
- jy=y0+dy*[-6:1:7];
- [jX, jY]=meshgrid(jx,jy);
- jx=jX'; jx=jx(:); % współrzędne przecięć linii dla obrazu wzorcowego
- jy=jY'; jy=jy(:);
- rm=sqrt((jx-cx).^2+(jy-cy).^2); % promień do środka obrazu
- [rms,j]=sort(rm);
- imshow(ig), hold on
- plot(cy,cx,'r+') % punkt centralny
- plot(jY,jX,'bo') % punkty odniesienia
- % identyfikacja modelu algorytmem LS
- A=regress(rms,rs);
- %A=polyfit(rms,rs,3);
- R=((rms).^3*A(4)+(rms).^2*A(3)+(rms)*A(2)+A(1));
- figure, plot(rms,rs,'b.', rms,R,'g-', [0 3e2],[0 3e2],'r-')
- % prostowanie obrazka
- xx=1:sx;
- yy=1:sy;
- [XX,YY]=meshgrid(xx,yy);
- RR=sqrt((XX-cx).^2+(YY-cy).^2);
- RRr=RR*A(2)+RR.^2*A(3)+RR.^3*A(4);
- RRu=RRr./RR;
- i1r=interp2(i1g,(YY-cy).*RRu+cy,(XX-cx).*RRu+cx);
- figure,
- subplot(2,1,1),imagesc(i1g)
- subplot(2,1,2),imagesc(i1r)
- colormap gray
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement