How to put value in symbolic variable in differential equation (Newton Raphson Method)?

조회 수: 1 (최근 30일)
hi
i need help in the following code. i require "df" value in numeric form but here i get the complete expressions due to syms alpha1 alpha2 alpha3. Kindly help me and guide me how i get results of "df" and "inv(df)" in numeric format. kindly help me please :)
with best regards Mudasir
alpha1=0.2;
alpha2=0.4;
alpha3=0.6;
v1desired=10;
T=[v1desired 0 0]';
f1=[ cos(alpha1)+cos(alpha2)+cos(alpha3)
cos(5*alpha1)+cos(5*alpha2)+cos(5*alpha3)
cos(7*alpha1)+cos(7*alpha2)+cos(7*alpha3)];
syms alpha1 alpha2 alpha3
f=[ cos(alpha1)+cos(alpha2)+cos(alpha3)
cos(5*alpha1)+cos(5*alpha2)+cos(5*alpha3)
cos(7*alpha1)+cos(7*alpha2)+cos(7*alpha3)];
df=jacobian(f,[alpha1;alpha2;alpha3])
dalpha=(inv(df))*(T-f1);
  댓글 수: 2
Walter Roberson
Walter Roberson 2016년 5월 15일
Mudasir Ahmed commented
Dear sir, i want to delete this question. because i post here my actual code of research. so i will be highly thankful to you if you delete this question please :) best regards mudasir
Walter Roberson
Walter Roberson 2016년 5월 15일
Musadir, your code contains algorithm that are in common use, nothing new or confidential. We will leave the question so that other people using the same kind of algorithm can learn from it.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2016년 5월 3일
v_alpha1=0.2;
v_alpha2=0.4;
v_alpha3=0.6;
v1desired=10;
T=[v1desired 0 0]';
syms alpha1 alpha2 alpha3
f1 = [ cos(alpha1)+cos(alpha2)+cos(alpha3)
cos(5*alpha1)+cos(5*alpha2)+cos(5*alpha3)
cos(7*alpha1)+cos(7*alpha2)+cos(7*alpha3)];
f = [ cos(alpha1)+cos(alpha2)+cos(alpha3)
cos(5*alpha1)+cos(5*alpha2)+cos(5*alpha3)
cos(7*alpha1)+cos(7*alpha2)+cos(7*alpha3)];
df = jacobian(f,[alpha1;alpha2;alpha3])
dalpha_sym = (inv(df))*(T-f1);
dalpha = double( subs(dalpha_sym, [alpha1, alpha2, alpha3], [v_alpha1, v_alpha2, v_alpha3]));
  댓글 수: 1
Walter Roberson
Walter Roberson 2016년 5월 5일
The inv() will fail when det(df)) is 0. You can solve(det(df),alpha1) and you will be given back a bunch of conditions. For example, the inv() will fail if alpha1 = alpha2. There is nothing you can do about that as long as you continue to use inv(). This is why inv() is not used in real problems.
You should consider substituting in numeric values first and then using pinv() instead of inv()

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by