MATLAB Answers

Oscarin
0

How can I make derivatives with several variables?

Asked by Oscarin
on 5 Sep 2018 at 21:43
Latest activity Commented on by Walter Roberson
on 20 Sep 2018 at 2:10

Hello I have a problem, I tryed to derive a equation like "a1^2*a2^2" but I got "ans = 2*a1*a2^2", This result is correct but If we take as variable only "a1" but I need to take as varible "a1" and "a2". I want to get this becase is a multiplication:

I have used diff () this is my code:

what is the correct way to say matlab which are my variables?

Thank you very much I wait for your answer.

  0 Comments

Sign in to comment.

Products


Release

R2017b

2 Answers

Answer by D_coder on 15 Sep 2018 at 22:53
Edited by D_coder on 15 Sep 2018 at 22:53

You can try this

a = a1^2*a2^2;
diff(a,a1) + diff(a,a2);
ans =
2*a1^2*a2 + 2*a1*a2^2

  1 Comment

thaks for your answer but this is more difficult because I am developing a graphic interphase and I export the data and I need to derivate de ecuation but I need to derive with a lot of variable I show a example:

In this case the last Graphic Interphase exported the data and I need to derive with variables "d1", "d2" and "t1". That's difficult because the ecuation it's different each time.

I have a list of possible variables but not all of them always appear because some of them based on the analysis become 0

Thanks

Sign in to comment.


Answer by Walter Roberson
on 15 Sep 2018 at 23:43

You can use gradient() to find the diff(), and you could sum() the result.

  10 Comments

You can use pretty(), or you can use LiveScript .

I try to use pretty () but matlab show a error.

but this is the problema I fill in with this ecuation.

I want to get the first ecuation on next picture. But If it were possible to obtain it with the notation of the second equation, it would be better

BL = latex(B)

But then you would have to display the latex stored in BL somehow.

You cannot get the graphical format you want to store into a variable. That format is a graphical format that is not how MATLAB represents symbolic expressions internally. You can render into latex like I show, but the result is a character vector that cannot be operated on symbolically.

Sign in to comment.