حل دستگاه معادلات ماتریسی با n مجهول (متلب - MATLAB)
ارسالها: 1
موضوعها: 1
تاریخ عضویت: بهمن ۱۳۹۵
اعتبار:
0
سپاس ها 0
سپاس شده 0 بار در 0 ارسال
حالت من: هیچ کدام
۱۳۹۵/۱۱/۰۹, ۰۶:۲۲ ق.ظ
(آخرین تغییر در ارسال: ۱۳۹۶/۰۱/۱۴, ۰۲:۳۳ ب.ظ توسط admin.)
کد: for i=3:2:m-3
for j=3:2:n-3
((dX(i+1,j+2)+dX(i+1,j))+(dY(i+2,j+1)+dY(i,j+1)))*Pprim(i+1,j+1)=dX(i+1,j+2)*Pprim(i+1,j+3))+(dX(i+1,j)*Pprim(i+1,j-1))+(dY(i+2,j+1)*Pprim(i+3,j+1))+(dY(i,j+1)*Pprim(i-1,j+1))+((us(i+1,j)-us(i+1,j+2)))+(vs(i,j+1)-(vs(i+2,j+1)))% inside control volume
end
end
با سلام
برای حل کردن یک دستگاه معادلات با n مجهول که مقدار n میتواند مقادیر مختلفی باشد به چه صورت است . مثلا برای این مثال تمام متغییر ها موجود میباشد و ماتریس Pprim که یک ماتریس n*n می باشد که فرض میکنیم یه ماتریس صفر باشد وبه جای مقادیری که در بالا ادرس دهی شده مقدار درست قرار بگیرد .
در کل برای دستگاه معادلاتی که تعداد n معادله , n مجهول دارد به چه صورت است . یعنی نوشتن ماتریس ضرایب عملا ممکن نیست و چون بالفرض یک بار این ماتریش 60*60 و یک بار دیگر با تعریف n می شود 50*50 و .....
با تشکر
کد پیاچپی: for i=3:2:m-3 for j=3:2:n-3 ((dX(i+1,j+2)+dX(i+1,j))+(dY(i+2,j+1)+dY(i,j+1)))*Pprim(i+1,j+1)=dX(i+1,j+2)*Pprim(i+1,j+3))+(dX(i+1,j)*Pprim(i+1,j-1))+(dY(i+2,j+1)*Pprim(i+3,j+1))+(dY(i,j+1)*Pprim(i-1,j+1))+((us(i+1,j)-us(i+1,j+2)))+(vs(i,j+1)-(vs(i+2,j+1)))% inside control volume end end
سپاس شده توسط | |
|
حل دستگاه معادلات ماتریسی با n مجهول (متلب - MATLAB)
ارسالها: 1
موضوعها: 0
تاریخ عضویت: فروردین ۱۳۹۶
اعتبار:
0
سپاس ها 0
سپاس شده 2 بار در 1 ارسال
حالت من: هیچ کدام
۱۳۹۶/۰۱/۱۲, ۱۲:۰۲ ب.ظ
(آخرین تغییر در ارسال: ۱۳۹۶/۰۱/۱۴, ۰۲:۳۲ ب.ظ توسط admin.)
سلام از دستور زیر استفاده کنید.
equationsToMatrix Convert linear equations to matrix notation.
[A,b] = equationsToMatrix([eq1,eq2,eq3,...],[x1,x2,...,xn]) converts
the equations eq1,eq2,eq3,... to matrix notation. Equations need to be
linear in the variables specified as second argument. eq1,eq2,eq3,...
can be SYM equations or simply SYM objects. In case eq1,eq2,eq3,...
are generic SYM objects, they will be interpreted as left sides
of equations, whose right sides are equal to 0. The equations just
need to be linear in the given variables, it does not play a role how
they are ordered or on which side of the equations the unknowns show up.
[A,b] = equationsToMatrix([eq1,eq2,eq3,...]) converts the equations
[eq1,eq2,eq3,...] to matrix notation. Equations need to be linear in
all variables of the equations. The system is interpreted as a linear
system of equations in the variables symvar([eq1,eq2,eq3,...]).
[A,b] = equationsToMatrix(eq1,eq2,eq3,...,x1,x2,...,xn) does the same
as equationsToMatrix([eq1,eq2,eq3,...],[x1,x2,...,xn]).
[A,b] = equationsToMatrix(eq1,eq2,eq3,...) does the same as
equationsToMatrix([eq1,eq2,eq3,...]).
If you do not assign the output to variables A and b or just assign the
output to a single variable, only the matrix A will be returned.
Examples:
syms x y z
eq1 = x + y + z
eq2 = x - 2*y - 5*z == 0
eq3 = x - z == 1
[A,B] = equationsToMatrix([eq1,eq2,eq3],[x,y,z])
A = equationsToMatrix([eq1,eq2,eq3],[x,y,z])
[A,B] = equationsToMatrix(eq1,eq2,eq3,x,y,z)
A = equationsToMatrix(eq1,eq2,eq3,x,y,z)
[A,B] = equationsToMatrix([eq1,eq2,eq3])
A = equationsToMatrix([eq1,eq2,eq3])
[A,B] = equationsToMatrix(eq1,eq2,eq3)
A = equationsToMatrix(eq1,eq2,eq3)
|