How to symbolically calculate the curl of a vector
3 views (last 30 days)
Show older comments
so basically i want to do this:
syms E1(x,y,z) E2(x,y,z) E3(x,y,z)
Ecurl=symcurl(x,y,z,E1,E2,E3)
function Ecurl = symcurl(x,y,z,E1,E2,E3)
Ecurl1 = diff(E2,z)-diff(E3,y)
Ecurl2 = diff(E3,x)-diff(E1,z)
Ecurl3 = diff(E1,y)-diff(E2,x)
Ecurl=[Ecurl1 Ecurl2 Ecurl3]
end
with the builtin curl function of matlab. When i try it like this:
syms x y z E1 E2 E3
curl([x,y,z],[E1,E2,E3])
i get a zero vector. And like this:
syms E1(x,y,z) E2(x,y,z) E3(x,y,z)
curl([x,y,z],[E1,E2,E3])
i get an error message that the second argument must be a vector of three variables. In the end i want to be able to use the subs command to assign a specific function to E1 E2 E3 at a later time. Thanks.
0 Comments
Accepted Answer
David Goodmanson
on 16 Nov 2017
Edited: David Goodmanson
on 16 Nov 2017
Hi Max, this appears to work.
>> minusdBdt = curl([E1,E2,E3],[x,y,z])
minusdBdt(x, y, z) =
diff(E3(x, y, z), y) - diff(E2(x, y, z), z)
diff(E1(x, y, z), z) - diff(E3(x, y, z), x)
diff(E2(x, y, z), x) - diff(E1(x, y, z), y)
(It's correct for a right hand coordinate system and opposite in sign from symcurl above)
>>
0 Comments
More Answers (0)
See Also
Categories
Find more on Numbers and Precision in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!