2021-03-20
  • |
  • daafoor
  • |
  • مشاهدات: 3520

برنامج لحل نظام المعادلات الخطية Ax = B : حيث يطلب من المستخدم إدخال عدد المعادلات وعناصر المصفوفة A و B:

%----------------------- Initialization Part ---------------------------
% Get the number of equations from the user
disp('This script for solve m-equation with m variable'); % Ax = B
m = input('m = '); 
while isempty(m) || ~isnumeric(m) 
m = input('m = '); 
end
% Check m value, it must be positive
while m <= 0 
disp('m must be positve ...'); 
m = input('m = '); 
end
% define an array of variables coefficients
A = ones(m,m); 
% define an array of constants
B = ones(1,m); 
% define an inverse array of variables coefficients array
inv_A = ones(m,m); 
% get variables coefficients from the user
current = 0; 
for i = 1:m 
for j = 1:m 
A(i,j)=input(['A(' num2str(i) ',' num2str(j) '):']); 
while (~isnumeric(A(i,j)) || isempty(A(i,j)) )
A(i,j) = input('');
end
end
end
% Get constants from the user
for i = 1:m 
B(1,i)=input(['B(' num2str(i) '):']); 
end
%----------------------- Calculation Part ---------------------------
% Calc variables coefficients array determinant
Det_A = det(A); 
% Calc the inverse variables coefficients array
inv_A = inv(A); 
% Find the solution and display it
x = inv_A*B'; 
%----------------------- Display Results Part ---------------------------
% display the variables coefficients array determinant
disp('Matrix A determinant is :') 
display(A); 
 
% display the constants array
display(B); 
% display the inverse of variables coefficients array
disp('The inverse of A is :'); 
display(inv_A); 
disp('The solution is :'); 
display(x); 

 

برنامج لتحويل درجة الحرارة من السيلسيوس إلى الفهرنهايت:

% This Programme to tranform Temp form Celsius to Fahrenheit
T_Ce=input('Enter Tempreture in Celsius ');
T_F=T_Ce*9/5+32; 
disp(['T= ' num2str(T_F) ' F']) 

 

 

برنامج لحساب التكامل لتابع:

syms t; 
f=exp(-t)*(t-2); 
I=int(f,-5,5);
a=vpa(I);
fprintf('Integral Equal %f \n',a)

 

 

 

برنامج يحسب صافي الدخل إذا علمت أن الضريبة الدخل  تكون كالتالي: 9 %على الدخول الأقل من 1200 دولار، 12 %على الدخول الأقل من 2200 دینار، 15 %على الدخول الأعلى:

Income=input('Enter the total income: ');
if(Income<1200)
Tax=0.09;
elseif(Income<2200)
Tax=0.12;
else
Tax=0.15;
end
disp(['Net income: ',num2str(Income*(1-Tax))])

 

 

برنامج لحساب جداء و قسمة كثيري حدود :

% This programm determine polynomial division and polynomial multiplication
% z3 = 10*z^5 -137*z^4 +105*z^3 -134*z^2 +12*z + 45;
z3=[10,-137,105,-134,12,45];
% z2 = 10*z^2 + 4*z -2; 
z2=[10,4,-2];
% This function calculate Deconvolution and polynomial division z3/z2 return the quotient q and remainder r  
[q,r]=deconv(z3,z2)
% This function calculate Convolution and polynomial multiplication z3*z2 return the convolution of vectors u and v.
z4=conv(z2,z3)

 

هل أعجبك المحتوى؟

محتاج مساعدة؟ تواصل مع مدرس اونلاين الان!

التعليقات
لا يوجد تعليقات
لاضافة سؤال او تعليق على المشاركة يتوجب عليك تسجيل الدخول
تسجيل الدخول