My First Derivative is not correctly calculated in matlab
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
inzamam shoukat
il 21 Mar 2024
Commentato: inzamam shoukat
il 21 Mar 2024
syms yApprox(X1) a0 a1 a2 a3 a4 a5 a6
yApprox = a0 + a1.*X1 + a2.*(X1).^2 + a3.*(X1).^3+ a4.*(X1).^4 + a5.*(X1).^5 + a6.*(X1).^6;
BC1= subs(yApprox,X1,0)
BC2 =subs((diff(yApprox)),X1,0) %The answer is suppose to be a1 but instead of that i got 1
0 Commenti
Risposta accettata
Bruno Luong
il 21 Mar 2024
Modificato: Bruno Luong
il 21 Mar 2024
syms yApprox(X1) a0 a1 a2 a3 a4 a5 a6
yApprox = a0 + a1.*X1 + a2.*(X1).^2 + a3.*(X1).^3+ a4.*(X1).^4 + a5.*(X1).^5 + a6.*(X1).^6;
BC1= subs(yApprox,X1,0)
BC2 =subs((diff(yApprox,X1)),X1,0) % pay attention to diff(..)
Più risposte (1)
Manikanta Aditya
il 21 Mar 2024
Hey,
Looks like the issue you are encountering is due to the differentiation operation. When you differentiate 'yApprox' with respect to X1, the coefficient a1 is treated as a constant, and the derivative of X1 with respect to X1 is 1. That’s why you’re getting 1 instead of a1.
syms X1 a0 a1 a2 a3 a4 a5 a6
yApprox = a0 + a1.*X1 + a2.*(X1).^2 + a3.*(X1).^3+ a4.*(X1).^4 + a5.*(X1).^5 + a6.*(X1).^6;
BC1= subs(yApprox,X1,0);
diff_yApprox = diff(yApprox, X1);
BC2 = subs(diff_yApprox, X1, 0);
In this code, 'diff_yApprox' is the derivative of 'yApprox' with respect to X1. When X1=0 is substituted into 'diff_yApprox', the result should be a1 as expected.
Thanks!
Vedere anche
Categorie
Scopri di più su Assumptions in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!