%in the name of God hold on r =26; turn = 50; tetha = 0:0.003:2*turn*pi; r1 = randi(15); r2 = randi(200); speed = r1 + 1 / r2; x = cos(tetha) * r + cos(speed*tetha) * 6; y = sin(tetha) * r + sin(speed*tetha) * 6; plot(x, y, 'r'); r=9; turn = 50; tetha = 0:0.003:2*turn*pi; r1 = randi(15); r2 = randi(200); speed = r1 + 1 / r2; x = cos(tetha) * r + cos(speed*tetha) * 8; y = sin(tetha) * r + sin(speed*tetha) * 8; plot(x, y, 'g'); ylabel( ['nooh124.blog.ir'] ) axis equal; axis([-32.5 32.5 -32.5 32.5]) print -dpng figure.png
%Moving k-means algorithm close all; clear all; clc; q11=imread('micro2.png'); q1=rgb2gray(q11); figure,imshow(q1); kk1=0; kk2=0; akk1=0; akk2=0; %x=ceil(255*rand); %y=ceil(255*rand); figure,imhist(q1); x=220; y=11; x1=0; y1=0; for i=1:272 for j=1:256 k1=q1(i,j)-x; if(k1<0) k1=k1*(-1); end k1=k1^2; k2=q1(i,j)-y; if(k2<0) k2=k2*(-1); end k2=k2^2; if(k1<k2) q2(i,j)=0; else q2(i,j)=255; end end end k1=1; k2=1; n1=0; n2=0; clear kk1; clear kk2; kk1=0; kk2=0; for i=1:272 for j=1:256 if(q2(i,j)==255) kk1(k1)=q1(i,j); k1=k1+1; n1=n1+1; else kk2(k2)=q1(i,j); k2=k2+1; n2=n2+1; end end end akk1=kk1(:); sumkk1=sum(akk1); akk2=kk2(:); sumkk2=sum(akk2); x1=sumkk1/n1; y1=sumkk2/n2; fc1=0; fc2=0; nc=n1+n2; for aq1=1:20 for i=1:272 for j=1:256 if(q2(i,j)==255) d1=q1(i,j)-x1; d1=d1^2; fc1=fc1+d1; else d2=q1(i,j)-y1; d2=d2^2; fc2=fc2+d2; end end end if(fc1>fc2) n=0; fcl=fc1; fcs=fc2; cl=x1; cs=y1; ncl=n1; ncs=n2; else n=1; fcl=fc2; fcs=fc1; cl=y1; cs=x1; ncl=n2; ncs=n1; end n11=fcs/fcl; if(n11>0&&n11<(1/3)) break; else for i=1:272 for j=1:256 if(n==0) if(q2(i,j)==255 &&q1(i,j)>fcl) q2(i,j)=0; end else if(q2(i,j)== 0 &&q1(i,j)>fcl) q2(i,j)=255; end end end end scs=0; scl=0; for i=1:272 for j=1:256 if(n==0) if(q2(i,j)==0) ncs=ncs+1; scs=scs+q1(i,j); else ncl=ncl+1; scl=scl+q1(i,j); end else if(q2(i,j)==255) ncs=ncs+1; scs=scs+q1(i,j); else ncl=ncl+1; scl=scl+q1(i,j); end cs=(1/ncs)*(scs); cl=(1/ncl)*(scl); n11=n11-(n11/nc); if(n==0) x1=cl; y1=cs; else x1=cs; y1=cl; end end end end end end figure,imshow(uint8(q2));
clc; clear; ydata=[1 1 2 1/(0.05+j*0.15) 0 0; 2 1 3 1/(0.10+j*0.30) 0 0; 3 2 3 1/(0.15+j*0.45) 0 0; 4 2 4 1/(0.10+j*0.30) 0 0; 5 3 4 1/(0.05+j*0.15) 0 0]; elements=max(ydata(:,1)); yprimitive=zeros(elements,elements); for i=1:elements; yprimitive(i,i)=ydata(i,4); if (ydata(i,5)~= 0); j=ydata(i,5); ymutual=ydata(i,6); yprimitive(i,j)=ymutual; end end buses=max(max(ydata(2,:)),max(ydata(3,:))); A=zeros(elements,buses); for i=1:elements; if ydata(i,2)~=0; A(i,ydata(i,2))=1; end if ydata(i,3)~=0; A(i,ydata(i,3))=-1; end end YBUS=A'*yprimitive*A; disp('Y bus matrix is:'); disp(YBUS);
x = [1 2 3 4 5 6 7 8 9 10]; y1 = [.16 .08 .04 .02 .013 .007 .004 .002 .001 .0008 ]; y2 = [.16 .07 .03 .01 .008 .003 .0008 .0003 .00007 .00002 ]; semilogy(x,y1,'-bo;y1;',x,y2,'-kx;y2;'); title('Plot title'); xlabel('X Axis'); ylabel('Y Axis'); print -dpng figure.png
%in the name of God turn = 70; format long r1 = randi(20) r2 = randi(1200) speed = r1 + 1 / r2; tetha = 0:0.003:2*turn*pi; r =10; x = cos(tetha) * r + cos(speed*tetha) * 5.5; y = sin(tetha) * r + sin(speed*tetha) * 5.5; plot(x, y, 'k'); ylabel( ['r1 = ',num2str(r1),' , r2 = ',num2str(r2)] ) axis equal; axis([-16.1 16.1 -16.1 16.1]) print -dpng figure.png
%for frequency 150 Hz fs=8000; A=1; f=150; t=0:127; x1=A*sin(2*pi*f/fs*t); subplot(2,3,1); plot(t,x1); xlabel('time'); ylabel('amplitude'); title('sinusoidal signal x1'); %for frequency 450 Hz fs=8000; A=1; f=450; t=0:127; x2=A*sin(2*pi*f/fs*t); subplot(2,3,2); plot(t,x2); xlabel('time'); ylabel('amplitude'); title('sinusoidal signal x2'); %for frequency 1500 Hz fs=8000; A=1; f=1500; t=0:127; x3=A*sin(2*pi*f/fs*t); subplot(2,3,3); plot(t,x3); xlabel('time'); ylabel('amplitude'); title('sinusoidal signal x3'); %for delaying in x1 y1=x1-20; subplot(2,3,4) plot(t,y1); xlabel=('time'); ylabel=('amplitude'); title=('delayed signal'); % signal after adding x1 and x2 xadd= x1 + x2 ; subplot(2,3,5); plot(t,xadd); xlabel=('time'); ylabel=('amplitude'); title=('result of addition of x1 and x2'); %multiply of signal x1 and x3 xmult=x1.*x3; subplot(2,3,6); plot(t,xmult); xlabel=('time'); ylabel=('ampliude'); title=('result of multiplication of x1 and x3');
%in the name of God turn = 70; format long r1 = randi(20) r2 = randi(1200) speed = r1 + 1 / r2; tetha = 0:0.003:2*turn*pi; r =10; x = cos(tetha) * r + cos(speed*tetha) * 6; y = sin(tetha) * r + sin(speed*tetha) * 6; plot(x, y, 'r'); axis equal; axis([-16.1 16.1 -16.1 16.1]) print -dpng figure.png
%in the name of God turn = 70; format long r1 = randi(20) r2 = randi(200) speed = r1 + 1/r2 tetha = 0:0.003:2*turn*pi; r =10; x = cos(tetha) * r + cos(speed*tetha) * 6; y = sin(tetha) * r + sin(speed*tetha) * 6; plot(x, y, 'r'); axis equal; axis([-16.1 16.1 -16.1 16.1]) print -dpng figure.png
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more