3-Laboratoriya ishi Furye qatori asosida raqamli signallar yetakchi garmonikalarini aniqlash
17-variant
import math
def sum(f, w, t, k):
sumfsin = 0
for i in range(len(f)-1):
sumfsin += f[i]*(math.sin(k) * (w[k] * (i + 1 /2)) * (t[k] - t[k-1])- math.sin(k) * w[k] * (i-1 / 2) * (t[k] - t[k-1]) )
return sumfsin
t = []
k = 0
w = [0]
a = []
T = 2 * math.pi
for i in range(0, 21):
t.append(k)
k += 0.000005
k = 0
for i in range(1, 21):
w.append(2 * math.pi / t[i])
f = [0, 11.41254, 7,054143, -7,05414
, -11,4132, 0,00222, 11,41185, 7,055941, -7,05054, -11,4139, -0,0045, -0,00445, 11,41117, 7,05774, -7,0487, -11,4146, -0,0067, 11,4105, 7,05954, -7,04695, -0,00889]
sumhf = 0
for i in range(len(f)-1):
sumhf += (t[i] - t[i-1]) * f[i]
a.append(2/T * (t[0] / 2 * f[0] + sumhf + t[-1] / 2 * f[-1]))
b = [0]
for i in range(1, 21):
a.append(2/(i * w[i] * T)*(f[0] * math.sin(i * w[i] * (t[i] - t[i-1]) / 2) + sum(f, w , t, i) + f[-1] * (math.sin(i) * w[i] * T - math.sin(i) * w[i] * (T - (t[i] - t[i-1])))))
print(a)
for i in range(1, 21):
b.append(2/(i * w[i] * T)*(f[0] * math.cos(i * w[i] * (t[i] - t[i-1]) / 2) + sum(f, w , t, i) + f[-1] * (math.cos(i) * w[i] * T - math.cos(i) * w[i] * (T - (t[i] - t[i-1])))))
print(b)
c = []
l = []
for i in range(1, 21):
c.append(math.sqrt(a[i]**2 + b[i]**2))
l = c
c.sort();
c.reverse()
Jadval ko’rinishida berilgan funktsiyalar uchun eng kichik kvadratlar usuli. Empirik bog’lanish qonunlarining chiziqli va kvadratik modeli
#include
#include
#include
using namespace std;
int main()
{
int i,j,k,n;
cout<<"\nelementlar soni\n";
cin>>n;
double x[n],y[n],a,b;
cout<<"\nx elementnini qiymati:\n";
for (i=0;icin>>x[i];
cout<<"\nEnter the y-axis values:\n";
for (i=0;icin>>y[i];
double xsum=0,x2sum=0,ysum=0,xysum=0;
for (i=0;i{
xsum=xsum+x[i];
ysum=ysum+y[i];
x2sum=x2sum+pow(x[i],2);
xysum=xysum+x[i]*y[i];
}
a=(n*xysum-xsum*ysum)/(n*x2sum-xsum*xsum);
b=(x2sum*ysum-xsum*xysum)/(x2sum*n-xsum*xsum);
double y_fit[n];
for (i=0;iy_fit[i]=a*x[i]+b;
cout<<"S.no"<cout<<"-----------------------------------------------------------------\n";
for (i=0;icout<cout<<"\nThe linear fit line is of the form:\n\n"<return 0;
}
Dostları ilə paylaş: |