soly64
06-08-2006, 01:51 AM
اولا اعذروني ان البرنامج نقل بال notepad ولكن لامشكله لمن لديه الماتلاب وارجوا ان تستفيدو منه وانا في انتظار اي أسئله بخصوصه
disp('WELCOME IN RENZ64 PROGRAME')
disp('Enter 1 for low pass filter and 2 for high pass filter')
disp('Enter 3 for RL connection and 4 for RC connection')
disp('If you want any filter type press 1 then 3')
A=0;
while A~=1 & A~=2
A=input('please enter the filter type 1 or 2\n');
if A~=1 & A~=2
disp('please enter the specified number for filter type 1 or 2')
end
end
while isempty(A)==1 |A~=1 & A~=2
A=input('please enter the specified number for filter type 1 or 2\n');
% % if isempty(A)==1
% % disp('please enter the specified number for filter type 1 or 20')
% % disp(' please enter the filter type 1 or 2\n')
% end
end
B=0;
while B~=3 & B~=4
B=input('please enter the connection type 3 or 4\n');
if B~=3 & B~=4
disp('please enter the specified number for connection type 3 or 4')
end
end
while isempty(B)==1 |B~=3 & B~=4
B=input('please enter the specified number for conection type 3 or 4\n');
% if isempty(B)==1
% disp('please enter the specified number for connection type 3 or 40')
% disp(' please enter the connection type 3 or 4\n')
% end
end
Wc=input('please Enter the value of Wc\n');
R=linspace(500,10000,40);
L=linspace(.1,4,40);
C=linspace(.1,4,40)*1e-6;
% low pass filter and RL connection
if A==1&B==3
for i=1:length(R)
w(i,:)=R(i)./L;
end
w;
w1=[w(1,:) w(2,:) w(3,:) w(4,:) w(5,:) w(6,:) w(7,:) w(8,:) w(9,:) w(10,:) w(11,:) w(12,:) w(13,:) w(14,:) w(15,:) w(16,:) w(17,:) w(18,:) w(19,:) w(20,:) w(21,:) w(22,:) w(23,:) w(24,:) w(25,:) w(26,:) w(27,:) w(28,:) w(29,:) w(30,:) w(31,:) w(32,:) w(33,:) w(34,:) w(35,:) w(36,:) w(37,:) w(38,:) w(39,:) w(40,:)];
w2=length(w1);
c=Wc-w1(1);
t=abs(c);
for j=1:length(w1)
a=Wc-w1(j);
n=abs(a);
if n<=t
t=n;
m1=w1(j)-n;
nearst_wc=m1+t;
end
end
nearst_wc;
[r c]=find(w==nearst_wc);
r=r(1);
c=c(1);
ohm=R(r);
henry=L(c);
fprintf('The required resistance equal:%f Ohm\n',ohm)
fprintf('The required coil equal:%f H\n',henry)
% High pass filter and RL connection
elseif A==2&B==3
for i=1:length(R)
w(i,:)=R(i)./L;
end
w;
w1=[w(1,:) w(2,:) w(3,:) w(4,:) w(5,:) w(6,:) w(7,:) w(8,:) w(9,:) w(10,:) w(11,:) w(12,:) w(13,:) w(14,:) w(15,:) w(16,:) w(17,:) w(18,:) w(19,:) w(20,:) w(21,:) w(22,:) w(23,:) w(24,:) w(25,:) w(26,:) w(27,:) w(28,:) w(29,:) w(30,:) w(31,:) w(32,:) w(33,:) w(34,:) w(35,:) w(36,:) w(37,:) w(38,:) w(39,:) w(40,:)];
w2=length(w1);
c=Wc-w1(1);
t=abs(c);
for j=1:length(w1)
a=Wc-w1(j);
n=abs(a);
if n<=t
t=n;
m1=w1(j)-n;
nearst_wc=m1+t;
end
end
nearst_wc;
[r c]=find(w==nearst_wc);
r=r(1);
c=c(1);
ohm=R(r);
henry=L(c);
fprintf('The required resistance equal:%f Ohm\n',ohm)
fprintf('The required coil equal:%f H\n',henry)
% low pass filter RC connection
elseif A==1&B==4
for j=1:length(C)
x(j,:)=1./(C(j).*R);
end
x;
x1=[x(1,:) x(2,:) x(3,:) x(4,:) x(5,:) x(6,:) x(7,:) x(8,:) x(9,:) x(10,:) x(11,:) x(12,:) x(13,:) x(14,:) x(15,:) x(16,:) x(17,:) x(18,:) x(19,:) x(20,:) x(21,:) x(22,:) x(23,:) x(24,:) x(25,:) x(26,:) x(27,:) x(28,:) x(29,:) x(30,:) x(31,:) x(32,:) x(33,:) x(34,:) x(35,:) x(36,:) x(37,:) x(38,:) x(39,:) x(40,:)];
c=Wc-x1(1);
t=abs(c);
for i=1:length(x1)
m=Wc-x1(i);
n=abs(m);
if n<=t
t=n;
m1=x1(i)-n;
nearest_WC=m1+t;
end
end
nearest_WC ;
[r c]=find(x==nearest_WC);
r=r(1);
c=c(1);
f=C(r);
o=R(c);
fprintf('The required resistance equal:%f Ohm\n',o)
fprintf('The required Capacitor equal:%f F\n',f)
% High pass filter RC connection
elseif A==2&B==4
for j=1:length(C)
x(j,:)=1./(C(j).*R);
end
x;
x1=[x(1,:) x(2,:) x(3,:) x(4,:) x(5,:) x(6,:) x(7,:) x(8,:) x(9,:) x(10,:) x(11,:) x(12,:) x(13,:) x(14,:) x(15,:) x(16,:) x(17,:) x(18,:) x(19,:) x(20,:) x(21,:) x(22,:) x(23,:) x(24,:) x(25,:) x(26,:) x(27,:) x(28,:) x(29,:) x(30,:) x(31,:) x(32,:) x(33,:) x(34,:) x(35,:) x(36,:) x(37,:) x(38,:) x(39,:) x(40,:)];
c=Wc-x1(1);
t=abs(c);
for i=1:length(x1)
m=Wc-x1(i);
n=abs(m);
if n<=t
t=n;
m1=x1(i)-n;
nearest_WC=m1+t;
end
end
nearest_WC ;
[r c]=find(x==nearest_WC);
r=r(1);
c=c(1);
f=C(r);
o=R(c);
fprintf('The required resistance equal:%f Ohm\n',o)
fprintf('The required Capacitor equal:%f F\n',f)
end
disp('WELCOME IN RENZ64 PROGRAME')
disp('Enter 1 for low pass filter and 2 for high pass filter')
disp('Enter 3 for RL connection and 4 for RC connection')
disp('If you want any filter type press 1 then 3')
A=0;
while A~=1 & A~=2
A=input('please enter the filter type 1 or 2\n');
if A~=1 & A~=2
disp('please enter the specified number for filter type 1 or 2')
end
end
while isempty(A)==1 |A~=1 & A~=2
A=input('please enter the specified number for filter type 1 or 2\n');
% % if isempty(A)==1
% % disp('please enter the specified number for filter type 1 or 20')
% % disp(' please enter the filter type 1 or 2\n')
% end
end
B=0;
while B~=3 & B~=4
B=input('please enter the connection type 3 or 4\n');
if B~=3 & B~=4
disp('please enter the specified number for connection type 3 or 4')
end
end
while isempty(B)==1 |B~=3 & B~=4
B=input('please enter the specified number for conection type 3 or 4\n');
% if isempty(B)==1
% disp('please enter the specified number for connection type 3 or 40')
% disp(' please enter the connection type 3 or 4\n')
% end
end
Wc=input('please Enter the value of Wc\n');
R=linspace(500,10000,40);
L=linspace(.1,4,40);
C=linspace(.1,4,40)*1e-6;
% low pass filter and RL connection
if A==1&B==3
for i=1:length(R)
w(i,:)=R(i)./L;
end
w;
w1=[w(1,:) w(2,:) w(3,:) w(4,:) w(5,:) w(6,:) w(7,:) w(8,:) w(9,:) w(10,:) w(11,:) w(12,:) w(13,:) w(14,:) w(15,:) w(16,:) w(17,:) w(18,:) w(19,:) w(20,:) w(21,:) w(22,:) w(23,:) w(24,:) w(25,:) w(26,:) w(27,:) w(28,:) w(29,:) w(30,:) w(31,:) w(32,:) w(33,:) w(34,:) w(35,:) w(36,:) w(37,:) w(38,:) w(39,:) w(40,:)];
w2=length(w1);
c=Wc-w1(1);
t=abs(c);
for j=1:length(w1)
a=Wc-w1(j);
n=abs(a);
if n<=t
t=n;
m1=w1(j)-n;
nearst_wc=m1+t;
end
end
nearst_wc;
[r c]=find(w==nearst_wc);
r=r(1);
c=c(1);
ohm=R(r);
henry=L(c);
fprintf('The required resistance equal:%f Ohm\n',ohm)
fprintf('The required coil equal:%f H\n',henry)
% High pass filter and RL connection
elseif A==2&B==3
for i=1:length(R)
w(i,:)=R(i)./L;
end
w;
w1=[w(1,:) w(2,:) w(3,:) w(4,:) w(5,:) w(6,:) w(7,:) w(8,:) w(9,:) w(10,:) w(11,:) w(12,:) w(13,:) w(14,:) w(15,:) w(16,:) w(17,:) w(18,:) w(19,:) w(20,:) w(21,:) w(22,:) w(23,:) w(24,:) w(25,:) w(26,:) w(27,:) w(28,:) w(29,:) w(30,:) w(31,:) w(32,:) w(33,:) w(34,:) w(35,:) w(36,:) w(37,:) w(38,:) w(39,:) w(40,:)];
w2=length(w1);
c=Wc-w1(1);
t=abs(c);
for j=1:length(w1)
a=Wc-w1(j);
n=abs(a);
if n<=t
t=n;
m1=w1(j)-n;
nearst_wc=m1+t;
end
end
nearst_wc;
[r c]=find(w==nearst_wc);
r=r(1);
c=c(1);
ohm=R(r);
henry=L(c);
fprintf('The required resistance equal:%f Ohm\n',ohm)
fprintf('The required coil equal:%f H\n',henry)
% low pass filter RC connection
elseif A==1&B==4
for j=1:length(C)
x(j,:)=1./(C(j).*R);
end
x;
x1=[x(1,:) x(2,:) x(3,:) x(4,:) x(5,:) x(6,:) x(7,:) x(8,:) x(9,:) x(10,:) x(11,:) x(12,:) x(13,:) x(14,:) x(15,:) x(16,:) x(17,:) x(18,:) x(19,:) x(20,:) x(21,:) x(22,:) x(23,:) x(24,:) x(25,:) x(26,:) x(27,:) x(28,:) x(29,:) x(30,:) x(31,:) x(32,:) x(33,:) x(34,:) x(35,:) x(36,:) x(37,:) x(38,:) x(39,:) x(40,:)];
c=Wc-x1(1);
t=abs(c);
for i=1:length(x1)
m=Wc-x1(i);
n=abs(m);
if n<=t
t=n;
m1=x1(i)-n;
nearest_WC=m1+t;
end
end
nearest_WC ;
[r c]=find(x==nearest_WC);
r=r(1);
c=c(1);
f=C(r);
o=R(c);
fprintf('The required resistance equal:%f Ohm\n',o)
fprintf('The required Capacitor equal:%f F\n',f)
% High pass filter RC connection
elseif A==2&B==4
for j=1:length(C)
x(j,:)=1./(C(j).*R);
end
x;
x1=[x(1,:) x(2,:) x(3,:) x(4,:) x(5,:) x(6,:) x(7,:) x(8,:) x(9,:) x(10,:) x(11,:) x(12,:) x(13,:) x(14,:) x(15,:) x(16,:) x(17,:) x(18,:) x(19,:) x(20,:) x(21,:) x(22,:) x(23,:) x(24,:) x(25,:) x(26,:) x(27,:) x(28,:) x(29,:) x(30,:) x(31,:) x(32,:) x(33,:) x(34,:) x(35,:) x(36,:) x(37,:) x(38,:) x(39,:) x(40,:)];
c=Wc-x1(1);
t=abs(c);
for i=1:length(x1)
m=Wc-x1(i);
n=abs(m);
if n<=t
t=n;
m1=x1(i)-n;
nearest_WC=m1+t;
end
end
nearest_WC ;
[r c]=find(x==nearest_WC);
r=r(1);
c=c(1);
f=C(r);
o=R(c);
fprintf('The required resistance equal:%f Ohm\n',o)
fprintf('The required Capacitor equal:%f F\n',f)
end